Export all Visio pages as HTML

Ease of Use


Version tested with


Submitted by:



Export all Visio pages in the document as HTML to the same path the Visio document resides in. 


Saving each sheet of the Visio Document as an HTML file. Each page will get it's own folder with all of the elements necessary to use as a web page. 


instructions for use


Option Explicit Sub ExportHTML() Dim PgObj As Visio.Page Dim Pgs As Visio.Pages Dim filename As String Dim PgName As String Dim iPgs As Integer 'Set a handle to the pages collection Set Pgs = Application.ActiveDocument.Pages 'Loop Pages collections For iPgs = 1 To Pgs.Count 'Set a handle to a page Set PgObj = Pgs(iPgs) 'Get Page name PgName = PgObj.Name 'Create path to save html file filename = Application.ActiveDocument.Path & PgName & ".html" 'Export the page as html file PgObj.Export filename Next iPgs 'Clean Up Set PgObj = Nothing Set Pgs = 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 ExportHTML in the list of macros.
  9. Press run.

Test the code:

  1. Open the example file.
  2. Run the ExportHTML 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: 168.03KB 

Approved by mdmackillop

This entry has been viewed 90 times.

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