I am using VBA to create text, and also to create a new TextStyle.
I can create the TextStyle no problem. I would like this new TextStyle to become the Default TextStyle for this drawing hereafter. Example. If I were to add new text, it would automatically be set to this new TextStyle.
I have managed to do exactly this for a Leader, but unable to do this for other text objects.
This is the code I currently have:
Dim newTextStyle As AcadTextStyle Dim currTextStyle As AcadTextStyle Set newTextStyle = ThisDrawing.TextStyles.Add("TextDefault") newTextStyle.SetFont "Arial", False, False, 1, 0 With newTextStyle .Height = 10 * myScale End With ThisDrawing.AcadTextStyle.Name = "TextDefault" 'Sets the default for the modelspace ThisDrawing.MTextStyle.Name = "TextDefault" ACAD.Regen 'Creates a LeaderStyle: LeaderDefault Set oDict = ThisDrawing.Dictionaries.Item("ACAD_MLEADERSTYLE") Dim oNewMLS As AcadMLeaderStyle Set oNewMLS = oDict.AddObject("LeaderDefault", "AcDbMLeaderStyle") ' Add the textstyle to the textstyles collection With oNewMLS .TextStyle = "TextDefault" .ArrowSize = 10 * myScale .ArrowSymbol = acArrowOpen30 '.ArrowheadSize = 10 * myScale 'Modify the Arrow Size '.ArrowheadType = acArrowOpen30 'Modify Arrow Type '.TextBackgroundFill = True 'Fill in the back of the text .TextHeight = 10 * myScale 'Specify Text Height .LandingGap = .TextHeight / 2 'Refers the spacing around the text '.TextLineSpacingStyle = acLineSpacingStyleAtLeast End With ThisDrawing.AcadMLeaderStyle.Name = "LeaderDefault" 'Sets the default for the modelspace
Any help of how to get "TextDefault" as the default style for the drawing after it is created would be heplful.
As I mentioned the code:
ThisDrawing.AcadMLeaderStyle.Name = "LeaderDefault"
DOES set the LeaderStyle to "LeaderDefault." I want this, but for other text objects.
This code:
ThisDrawing.AcadTextStyle.Name = "TextDefault" 'Sets the default for the modelspace ThisDrawing.MTextStyle.Name = "TextDefault"
Does NOT do that.
Thanks in advance.
So I just asnwered my own question so I thought I might as well post the answer.
To set the TextStyle I needed this line:
ThisDrawing.ActiveTextStyle = newTextStyle