Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I load the text style in VBA?

Status
Not open for further replies.

DougP

MIS
Dec 13, 1999
5,985
US
Any ACAD VBA guys here?
here is my code:
' ---------------------------------------
' insert into AutoCAD
Dim objAcadApp As AcadApplication
Dim ThisDrawing As AcadDocument
Set objAcadApp = GetObject(, "AutoCAD.Application")
objAcadApp.Visible = True
Set ThisDrawing = objAcadApp.ActiveDocument

Dim textObj As AcadText
Dim textString As String
Dim insertionPoint(0 To 2) As Double
Dim height As Double

Dim newTextStyle As AcadTextStyle
Dim currTextStyle As AcadTextStyle

Set currTextStyle = ThisDrawing.ActiveTextStyle
Set newTextStyle = ThisDrawing.TextStyles.Add("Code128")
ThisDrawing.ActiveTextStyle = newTextStyle

' Define the text object
textString = Me!Text2
insertionPoint(0) = 2: insertionPoint(1) = 2: insertionPoint(2) = 0

height = 0.5

ThisDrawing.Regen acActiveViewport
' Create the text object in model space
Set textObj = ThisDrawing.ModelSpace.AddText(textString, insertionPoint, height)

'finished set test style back
ThisDrawing.ActiveTextStyle = currTextStyle
--------------------------
This code creates a text entty but does not use the barcode style. How do I load the style in VBA?
I need to load a barcode font I created using VBA.


DougP, MCP
 
DougP,

You need to set the .fontFile property of the AcadTextStyle Object.

Set currTextStyle = ThisDrawing.ActiveTextStyle
Set newTextStyle = ThisDrawing.TextStyles.Add("Code128")
newTextStyle.fontFile = "Path to font file!"
ThisDrawing.ActiveTextStyle = newTextStyle

Good Luck,

Scott
 
Great
How can I set the Width factor? The default is usually 1.0, it needs to be 0.07, very skinny for the barcode to show correctly.

DougP, MCP
 
For some reason it does not work.
No error, but no result either
ACAD 2000

DougP, MCP
 
add this:
ThisDrawing.Regen acAllViewports

If that does not work, check to see if the .Width property was available in the 2000 API.

Scott
 
The width property is there. when I type a period after the
newTextStyle.
a list of items pops up and width is one of them.
But somethow I think it should be saying widthfactor
No?
width is in help too.
I'll try the regen command though next


DougP, MCP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top