Clean up Visio Masters

Anyone who has created Visio masters may have noticed that the masters may require cleanup. When selecting a master to edit, you may notice that the edit window seems to be empty and you  will need to center the image to bring it back in view. Other times, the shape is bigger than the page it is sitting on in the edit window. So, a little editing on the page shapesheet is required, either the values or grabbing the sides and readjusting.

I am not sure whether the cleanup actually makes a different, but it is less of a distraction when editing the masters.

Recently I was faced with the task of doing this cleanup to more than 500 shapes, so VBA to the rescue.

With a little research, I came up with

Visio.Master.ResizeToFitContents

So I used the following code to

Public Sub CleanMasters()
Dim vsoMaster As Visio.Master
Dim vsoMasterCopy As Visio.Master
Dim vsoShape As Visio.Shape
For Each vsoMaster In ActiveDocument.Masters
If vsoMaster.Type = 1 Then
Set vsoMasterCopy = vsoMaster.Open
vsoMasterCopy.ResizeToFitContents
vsoMasterCopy.Close
End If
Next vsoMaster
End Sub

So far this seems to work. I did notice that the page has a margin rather than being the same size as the master. No big deal. The key factor is that it is consistent.

Thanks JG for being a sounding board.

Enjoy…

John Marshall… Visio MVP Visio.MVPs.org

Published by johnvisiomvp

The original Visio MVP. I have worked with the Visio team since 1993

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s