I'm trying to change all text style font in a drawing document, regardless of the style they belong to. The problem is I'm getting an error while overwriting some text styles (it works for some styles, then I get the error below). Can someone help with this? I would really appreciate it.
Here is the code I'm using:
Dim oDDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oTM As TransactionManager = ThisApplication.TransactionManager
Dim oTS As TextStylesEnumerator = oDDoc.StylesManager.TextStyles
Dim sNameTextB As String = "MyTxtStyle"
Dim oStyleB As TextStyle = oTS.Item(sNameTextB)
Dim newTM As Transaction = oTM.StartTransaction(oDDoc, "ChangeTextStyle")
For Each oStyleA As TextStyle In oDDoc.StylesManager.TextStyles
If oStyleA.Font <> oStyleB.Font Then
oStyleA.Font = oStyleB.Font
End If
Next oStyleA
newTM.End()
Solved! Go to Solution.
Solved by dialunau. Go to Solution.
It turns out that running the code would try to change all style, including the not in use text styles included in the global styles, so I just had to tweak the code to work only on the in use text styles and now it works just fine.
Can't find what you're looking for? Ask the community or share your knowledge.