Using the Save as Web Page Object Model from Visual Basic: An Example
Last modified: October 23, 2012
Applies to: Office 2013 | Visio 2013
To use the Save as Web Page API in your Microsoft Visual Basic project, set a reference in your project to Microsoft Visio 15.0 Save As Web Type Library.
In the Microsoft Visual Basic Editor included with Microsoft Visio, you can find the list of available references by clicking References on the Tools menu. In Microsoft Visual Basic 6.0, you can find this list by clicking References on the Project menu.
The Save as Web Page model contains two classes: VisSaveAsWeb and VisWebPageSettings, which implement the IVisSaveAsWeb and IVisWebPageSettings interfaces, respectively.
A VisSaveAsWeb object implements the methods that perform the Web page creation process.
A VisWebPageSettings object contains the properties of your Web page project.
When you create a Web page and its supporting files (also called a Web page project), you'll typically follow these steps.
Use the SaveAsWebObject property of the Visio Application object to get an instance of a VisSaveAsWeb object.
Use the WebPageSettings property of the VisSaveAsWeb object to get a reference to a VisWebPageSettings object, which you can use to get or set the Web page settings for your project.
Set the properties of the VisWebPageSettings object.
You must always provide a target path for your files.
Call the AttachToVisioDoc method to identify the document to save as a Web page. If you don't specify which document to save, the active drawing is saved.
Call the CreatePages method to begin the Save as Web Page operation.
The following procedure shows how to open a new Web page project, set selected properties, and create the Web page files.
Public Sub SaveAsWeb () Dim vsoSaveAsWeb As VisSaveAsWeb Dim vsoWebSettings As VisWebPageSettings ' Get a VisSaveAsWeb object that ' represents a new Web page project. Set vsoSaveAsWeb = Visio.Application.SaveAsWebObject ' Get a VisWebPageSettings object. Set vsoWebSettings = vsoSaveAsWeb.WebPageSettings ' Configure preferences. With vsoWebSettings .StartPage = 1 .EndPage = 2 .QuietMode = True .TargetPath = "c:\your_folder_name\your_filename.htm" End With ' Create the pages. Because no particular document ' is specified, the active drawing is saved. vsoSaveAsWeb.CreatePages End Sub