Visio

Change the font size of all shapes at once

Ease of Use

Easy

Version tested with

2003 

Submitted by:

Brandtrock

Description:

Change the font on all shapes in a Visio document page. 

Discussion:

Standardizing the font size on a Visio project that many persons have had input to can be time consuming. This routine will change all text in shapes to 12pt font. 

Code:

instructions for use

			

Option Explicit Public Sub FontChange() ' Change the font of all shapes to 12pt Dim shpObjs As Visio.Shapes Dim shpObj As Visio.Shape Dim celObj As Visio.Cell Dim i As Integer 'Reference to Shapes collection Set shpObjs = ActivePage.Shapes 'Loop Shapes collection to change font size For i = 1 To shpObjs.Count Set shpObj = shpObjs(i) Set celObj = shpObj.Cells("Char.Size") celObj.Formula = "=12 pt." ' or ' shapeObj.Cells("Char.Size[1] ").Formula = "= 12 pt." Next 'Clean up Set celObj = Nothing Set shpObj = Nothing Set shpObjs = Nothing End Sub

How to use:

  1. Open your Visio document.
  2. Press Alt + F11 to launch the Visual Basic Editor (VBE).
  3. Select Insert>Module from the Menu Bar in the VBE.
  4. Copy the code from above.
  5. Paste the code in the right hand window of the VBE.
  6. Close the VBE.
  7. From the Visio document, select Tools>Macro>Macros (or press Alt + F8).
  8. Highlight FontChange in the list of macros.
  9. Press run.
 

Test the code:

  1. Open the example file.
  2. Run the FontChange macro per the instructions above.
  3. When you are convinced that it works right, place the code in your document and run it.
 

Sample File:

VBAX_Visio3.zip 96.56KB 

Approved by mdmackillop


This entry has been viewed 65 times.

Please read our Legal Information and Privacy Policy
Copyright @2004 - 2020 VBA Express