Running Save as Web Page from the command line
See also
The Save as Web Page feature is automatically installed with each Microsoft Visio 2002 product. It is installed as a Visio add-on with the name "SaveAsWeb."
To run Save as Web Page using the command-line interface, you call the Save as Web add-on with the desired command-line options.
Note The command-line interface is the only way to control Save as Web Page from a separate executable.
You can choose either of the following techniques:
- Create a formula using the RUNADDONWARGS function in a shape’s event section.
This can be done in the ShapeSheet window without writing any code. For example, a user could create a shape with a call to RUNADDONWARGS in the shape's double-click event. They need only to double-click the shape to produce a Web page for the diagram. Using the Visio object model, you can also set formulas using a Cell object's Formula property.
For details about the RUNADDONWARGS function, Cell object, or Formula property, see the Microsoft Visio Developer Reference (on the Help menu, click Developer Reference).
For more details about using the RUNADDONWARGS function with Save as Web Page, see Using the RUNADDONWARGS function.
- Write a Microsoft Visual Basic macro in Visio (or code in a separate component) that launches the add-on using the Visio Automation object model. You can use the Run method of the Addon object and pass the command-line parameters to specify the properties of the Web page.
This technique sometimes means writing less code than doing so using the Save as Web Page object model, but requires familiarity with command-line parameters.
For details about the Addon object or Run method, see the Microsoft Visio Developer Reference (on the Help menu, click Developer Reference).
For more details about using the Run method to call Save as Web Page, see Calling the Run method of the SaveAsWeb add-on.
Save as Web Page command-line options
The format for command-line parameters look like the following:
/token = value where token is the option, and value is the option’s value.
The following table lists the command-line options for the Save as Web Page command-line interface. The column titled Method/Property name lists the corresponding method or property in the object model. For details about a particular option, see the corresponding method or property topic in this reference.
1 For the text/number value type, the user may specify text such as vml for the output type, or a number (for example, 1) representing the index of this output type. Each output type will have its own unique index. For screenres, text and number values are defined in http://msdn.microsoft.com/en-us/library/aa217877(v=office.10).aspx VISWEB_DISP_RES.
Using the RUNADDONWARGS function
The following is an example of using the RUNADDONWARGS function to call the Save as Web Page add-on.
=RUNADDONWARGS("SaveAsWeb","/target=c:\temp\mypage.htm /quiet /prop /startpage=1 /endpage=3 /altformat /priformat=vml /secformat=jpg /openbrowser") A previous scenario described a user being able to merely double-click a shape in a drawing to produce a Web page for that drawing. To demonstrate this, you can place the previous formula in the EventDblClick cell of the Events section in the ShapeSheet window of any shape on your drawing page (select a shape in the drawing window, then on the Window menu, click Show ShapeSheet). After the formula is entered into the ShapeSheet cell, you can double-click that shape in the drawing window and launch the Save as Web Page feature.
For more information about the RUNADDONWARGS function, the EventDblClick cell, and the Events section, see the Microsoft Visio Developer Reference (on the Help menu, click Developer Reference).
Calling the Run method of the SaveAsWeb add-on
The Save as Web Page feature is installed as a Visio add-on called SaveAsWeb and can be referenced through the Addons collection of the Visio Application object.
The following example demonstrates how to run the Save as Web Page add-on by passing command-line parameters to the Run method of the SaveAsWeb add-on.
In this example, the code that launches the add-on is contained in an event handler for the DocumentSaved event. The QuietMode is set to True so that the Save as Web Page dialogs are not displayed in the user interface.
Private Sub Document_DocumentSaved(ByVal Document As IVDocument) Application.Addons("SaveAsWeb").Run "/quiet=True _ /target=C:\temp\test.htm" End Sub For more information about the Addons and Application objects, and the DocumentSaved event, see the Microsoft Visio Developer Reference (on the Help menu, click Developer Reference).