• Skip to main content
  • Skip to primary sidebar
  • Skip to footer

bVisual

  • Home
  • Services
    • How Visio smartness can help your business
    • Visio visual in Power BI
    • Visio Consulting Services
    • Visio Bureau Services
    • Visio Training and Support Services
  • Products
    • Visio Shape Report Converter
    • SS Plus
    • LayerManager
    • visViewer
    • Metro Icons
    • Rules Tools for Visio
    • The Visio 2010 Sessions App
    • Multi-Language Text for Visio
    • Document Imager for Visio
    • multiSelect for Visio
    • pdSelect for Visio
  • Case Studies
    • Case studies overview
    • Using Visio in Education for GIS
    • Visualizing Construction Project Schedules
    • Visio Online Business Process Mapping
    • Nexans Visio Template
    • CNEE Projects, WorldCom
    • Chase Manhattan Bank
  • News
    • Recent news
    • News archive
  • Resources
    • Articles➡
      • ShapeSheet Functions A-Z
      • Comparing Visio for the Web and Desktop
      • Customising Visio Shapes for the Web App
      • Key differences between the Visio desktop and web apps
      • Using the Visio Data Visualizer in Excel
      • Using Visio in Teams
      • Creating Visio Tabs and Apps for Teams with SharePoint Framework (SPFx)
      • Designing Power Automate Flows with Microsoft Visio
      • Innovative uses of Visio Lists
    • Webcasts ➡
      • Visio in Organizations
      • My session and other Visio sessions at MSIgnite 2019
      • Power up your Visio diagrams
      • Vision up your Visio diagrams
      • The Visio 2010 MVP Sessions
    • Visio Web Learning Resources
    • Books➡
      • Visualize Complex Processes with Microsoft Visio
      • Mastering Data Visualization with Microsoft Visio
      • Microsoft Visio Business Process Diagramming and Validation
      • Visualizing Information with Microsoft Visio
  • Blog
    • Browse blog articles
    • Visio Power BI articles
    • Visio for Web articles
    • A history of messaging and encryption
  • About us
    • About bVisual
    • Testimonials
    • Bio of David Parker
    • Contact Us
    • Website Privacy Policy
    • Website terms and conditions
    • Ariba Network
You are here: Home / Visio / Visio 2010 / Cleaning Visio Documents

Published on January 7, 2015 by David Parker

Cleaning Visio Documents

A Visio user recently showed me a Visio 2010 document that could not be viewed with the Microsoft Visio Viewer. He could open it in Visio okay, but not in the viewer. Well I tried just removing the unused masters and styles, etc (of which there were quite a few), but that did not allow it to be viewed either. Then I tried the document.Clean() method, and, hey presto, the document could then be viewed. Unfortunately, the Clean() method is not available in the UI, so I have created a macro to make it more accessible.

The File / Info / Reduce File Size dialog shows that there are unused masters and styles :

image

I have created a stencil, Cleaner.vss, that contains one macro called CleanMe, which can be downloaded from the link below, and placed into My Shapes folder before opening in Visio.

It was necessary to enable macros in my installation of Visio 2010:

image

The macro can then be accessed from View / Macros:

image

The first option is to clean the document:

image

This option offers to remove unused masters from the document:

image

The next option offers to remove all unused themes, data graphics and styles:

image

The Visio document file size was reduced substantially:

image

This is the full VBA macro code:

Option Explicit
Public Sub CleanMe() 
On Error GoTo errHandler
Const title As String = "bVisual Cleanser"
Dim doc As Visio.Document
    If Visio.ActiveDocument Is Nothing Then
        GoTo exitHere
    Else
        Set doc = Visio.ActiveDocument
    End If
   
Dim iRet As Integer
    iRet = MsgBox("Do you want to clean the document " & doc.Name, vbYesNoCancel, title) 
    If iRet = vbCancel Then
        GoTo exitHere
    ElseIf iRet = vbYes Then
        doc.Clean
    End If
   
    iRet = MsgBox("Do you want to remove unused masters from " & doc.Name, vbYesNoCancel, title)
    If iRet = vbCancel Then
        GoTo exitHere
    ElseIf iRet = vbYes Then
        doc.RemoveHiddenInformation visRHIMasters
    End If
 
    iRet = MsgBox("Do you want to remove unused styles, themes, and other display formats from " & _
        doc.Name, vbYesNoCancel, title)
    If iRet = vbCancel Then
        GoTo exitHere
    ElseIf iRet = vbYes Then
        doc.RemoveHiddenInformation visRHIStyles
    End If
   
exitHere: 
    Exit Sub
errHandler: 
    MsgBox Err.Description
    Resume exitHere
End Sub

Of course, the document must be saved in order to see the file size reduction….

Alternatively, you can download the stencil from here: Cleaner.vss

Related

Filed Under: Visio 2010, Visio 2013 Tagged With: Visio

About David Parker

David Parker has 25 years' experience of providing data visualization solutions to companies around the globe. He is a Microsoft MVP and Visio expert.

Reader Interactions

Comments

  1. Steve Phillips says

    December 16, 2020 at 6:16 pm

    Hi David,

    A really useful post, as is the one to change the master shape for the org chart wizard, I have now created two templates one for a PBS and another for a WBS.

    My next step is be able to combine both in the same template. To do this I need to have a WBS and PBS master shape in my document stencil and then have a macro that then manipulates the shape within the stencil.

    For example, if the user runs a WBS Macro, this would delete the ‘Executive Shapetacular’ from the document stencil, copy and paste the WBS master shape, creating a new shape, this new shape then gets renamed to ‘Executive Shapetacular’ and set to ‘Match master by name’ in the properties; thus making it available and usable in the org chart wizard.

    I am struggling with the VBA, I am not a programmer, but have done Excel VBA.

    Any assistance / tips greatly appreciated.

    BR
    Steve

    Reply
    • David Parker says

      December 16, 2020 at 9:08 pm

      Sounds possible if you do it before any shape instances have been dropped. Note that Masters have both a Name and NameU property. I advise that you make them the same.

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

  • LinkedIn
  • Twitter

Recent Posts

  • Fixing dimensions of 2D shapes
  • Merging Linked Data from Similar Tables
  • Smart Radio Buttons and Check Boxes in Visio
  • Using Button Face Ids in Visio
  • Grid Snapping Revisited

Categories

Tags

Accessibility Add-Ins Connectors Containers Data Export Data Graphics Data Import Data Visualizer Educational Excel GraphDatabase Hyperlinks Icon Sets JavaScript LayerManager Layers Legend Link Data to Shapes Lists MSIgnite MVP Office365 Org Chart PowerApps PowerBI PowerQuery Processes Setup and Deployment Shape Data Shape Design ShapeSheet ShapeSheet Functions SharePoint 2013 SQL Teams Validation VBA Video Visio Visio 2007 Visio for the Web Visio Online Visio Services Visio Viewer Webinar

Footer

bVisual Profile

The UK-based independent Visio consultancy with a worldwide reach. We have over 25 years experience of providing data visualization solutions to companies around the globe.

Learn more about bVisual

  • Amazon
  • E-mail
  • Facebook
  • LinkedIn
  • Twitter
  • YouTube

Search this website

Recent posts

  • Fixing dimensions of 2D shapes
  • Merging Linked Data from Similar Tables
  • Smart Radio Buttons and Check Boxes in Visio
  • Using Button Face Ids in Visio
  • Grid Snapping Revisited

Copyright © 2025 · Executive Pro on Genesis Framework · WordPress · Log in