Is there a reliable way of setting font family in Visio VBA ?

Francis Vila 0 Reputation points
2023-11-24T10:35:17.3933333+00:00

I have 1 macro-enabled file ( .vsdm) with one stencil file containing macros (.vssm), and hundreds of .vsd and .vsdx files containing diagrams.

I use the macros to open the .vsdx files and make changes such as changing the font.

To change a font, from what I read, you can't just say this shape should have the font named 'arial'. You have to get the ID of the font (an integer) and apply that font, using a formula such as shp.CellsSRC(visSectionCharacter, 0, visCharacterFont).FormulaU = "238"

To get the id, I use a formula like font_ID = ActiveDocument.fonts.Item(fontName).ID

BUT the font IDs in the macro file appear not to be the same as in the .vsdx and .vsd files I open with the macro.

Therefore I GET A RANDOM FONT using this method.

How can I safely set the font family of a shape?

Microsoft 365
Microsoft 365
Formerly Office 365, is a line of subscription services offered by Microsoft which adds to and includes the Microsoft Office product line.
5,086 questions
Visio
Visio
A family of Microsoft products used to create diagrams and vector graphics.
99 questions
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,970 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.