qwer
qwer

Reputation: 31

VBA to change Visio font style by font name instead of font index?

I'm hoping to use VBA to change the font style of the texts in shapes(from Calibri to Verdana). Currently I have (a snippet of the code)

Visio.ActivePage.Shapes(1).Characters.CharProps(visCharacterFont) = 235# 

235 is the font index for Verdana in my system. However, the font index is very unstable and can change on different computers. Is there a way to change the font style by font name instead, e.g. ...="Verdana"? It's possible in excel, but I couldn't find similar syntax in Visio. Thanks in advance!

Upvotes: 3

Views: 1095

Answers (1)

Surrogate
Surrogate

Reputation: 1734

You can check what is ID for Verdana font on current PC

Dim Verdana_ID As Integer
Verdana_ID = ActiveDocument.Fonts.Item("Verdana").ID

And after this step set this ID as character's font

Visio.ActivePage.Shapes(1).Characters.CharProps(visCharacterFont) = Verdana_ID

Upvotes: 3

Related Questions