Microsoft KB Archive/278932

= Visio2000: Sample Macro to Navigate to Pages Within a Drawing =

Article ID: 278932

Article Last Modified on 1/29/2007

-

APPLIES TO


 * Microsoft Visio 2000 Standard Edition
 * Microsoft Visio 2000 Professional Edition
 * Microsoft Visio 2000 Technical Edition
 * Microsoft Visio 2000 Enterprise Edition

-



This article was previously published under Q278932



SUMMARY
The following Microsoft Visual Basic for Applications macro (Sub procedure) demonstrates how to navigate to different pages in Microsoft Visio by using a page's name or index.



MORE INFORMATION
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.

Use the Name Property
To go to a page by using its Name property, use the Application.Page property: Sub GoToPageByName On Error GoTo ErrorHandler   ' Enable error-handling routine. ActiveWindow.Page = &quot;Page-2&quot; MsgBox (&quot;You are now on Page-2 of the drawing.&quot;) Exit Sub       ' Exit to avoid error handler when no error occurred. ErrorHandler:             ' Error-handling routine. MsgBox (&quot;Your drawing does not have a page called Page-2.&quot;)

End Sub

Use the Page Index
To go to a page by its page index, use the GetNames method to fill an array; then use the array's index value as the argument for the ActiveWindow.Page property: Public Sub GoToPageByIndex

Dim PageNamesArray As String On Error GoTo ErrorHandler   ' Enable error-handling routine. ActiveDocument.Pages.GetNames PageNamesArray ' The array start with 0 for Page-1. ' Index the array to Page-2 in the Drawing ActiveWindow.Page = PageNamesArray(1) MsgBox (&quot;You are now on Page-2 of the drawing.&quot;) Exit Sub       ' Exit to avoid error handler when no error occurred. ErrorHandler:                   ' Error-handling routine. MsgBox (&quot;Your drawing does not have a second page.&quot;)

End Sub

