How to format text in shape via VBA?

Started by wxaggie11, March 09, 2011, 07:52:33 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

wxaggie11

I have a rectangle being drawn on the drawing and it's being filled with the text I'm asking... But how do I format it? I would like it to be size 6, font type Arial, and all caps. There must be a way to do this through VBA right?

Jumpy


Dim shp as Shape
Set shp = ActiveWindow.Selection(1)

shp.Cells("Char.Size").Formula = "6 pt"
shp.Cells("Char.Font"),Formula = 4 'Number for Arial in my system, can be different for you



The above only works, when the format is the same for all the Text. If you want to format individual words or characters, you have to use the Characters-Object of the shape and things get complicated.

P.S.: It's often a good idea to use the Macro-Recorder to get started.

wapperdude

For more insight an handling text and characters, the following might be of interest:

Running with Characters:  http://blogs.msdn.com/b/visio/archive/2006/08/18/704811.aspx
Running with Characters, Part 2:  http://blogs.msdn.com/b/visio/archive/2006/08/22/711391.aspx

VisioGuy has a large set of articles on texting.  This article is a good starter, and has links at the bottom to many more topics:
Top Twelve Text Tips,  http://www.visguy.com/2009/05/06/top-twelve-text-tips/

HTH
Wapperdude
Visio 2019 Pro