Sample Microsoft VBA Macro
For each drawing file that is open in the Microsoft Office Visio instance, the sample Microsoft Visual Basic for Applications (VBA) macro shown below does the following:
- Logs the name and path of the drawing file in the Immediate window
- Logs the name of each page in the Immediate window
Here is a look at the code in the program and what it does.
|
Here is an example of the program's output, assuming drawings named Office.vsd and Recycle.vsd are open and have been saved in the specified locations.
Note |
---|
The locations shown are not those in which Visio saves drawings by default. |
Sample output |
Description |
---|---|
|
The name of the first drawing |
|
|
|
The name of page 1 |
|
|
|
The name of page 2 |
|
|
|
The name of the second drawing |
|
|
|
The name of page 1 |
|
|
|
The name of page 2 |
|
|
|
The name of page 3 |
|
You can find more information about writing a program in the VBA environment and about the Visual Basic Editor in Microsoft Visual Basic Help (in the Visual Basic Editor window, on the Help menu, click Microsoft Visual Basic Help ).
You can find details about using a specific Visio object, property, method, enumeration, or event in the Microsoft Office Visio Automation Reference (on the Visio Help menu, click Developer Reference).
Note |
---|
If you did not install the Automation Reference at the time you installed Visio, clicking the Developer Reference command on the Help menu will automatically start its installation. |