Page Property [Visio 2003 SDK Documentation]
As it applies to the Layer object and Layers collection.
Gets the page that contains the layer or layers.
objRet = LayerOrLayersObj**.Page**
objRet The Page object that contains the layer or layers.
LayerOrLayersObj Required. An expression that returns a Layer object or Layers collection.
Version added
2.0
Remarks
If the Layer object or Layers collection is in a master rather than in a page, the Page property returns Nothing. You cannot set the Page property of a Layer object or Layers collection.
As it applies to the Window object.
Gets or sets the page that is displayed in a window.
objVariantRet = object**.Page**
object**.Page** = stringVariant
objVariantRet Variant. A Page object that represents the page being shown returned in a Variant.
object Required. An expression that returns a Window object.
stringVariant Required Variant. Contains a string that names the page to be shown.
Version added
2.0
Remarks
For the stringVariant argument, you can pass a locale-independent page name (a universal name), a locale-specific page name (a local name), or a Page object.
If a window is not showing a page (perhaps because it is showing a master), the Page property returns Nothing. You can use the Type property of the Window object to determine whether the Window object is showing a page. Otherwise, the returned Variant refers to the Page object that the window is showing.
Beginning with Visio 5.0b, the Page property no longer returns an exception if a window is not showing a page; it returns Nothing. You can use the following code to handle both return values:
'Close Window(intCounter) if it is showing a page.
Set vsoWindow = Windows(intCounter)
On Error Resume Next
Set vsoPage = vsoWindow.Page
On Error GoTo 0
If Not vsoPage Is Nothing Then
vsoWindow.Close
End If
Note In versions of Visio through version 4.1, the Page property of a Window object returned an Object (as opposed to a Variant of type Object) and the Page property of a Window object accepted a String (as opposed to a Variant of type String). Because of changes in Automation support tools, the property was changed to accept and return a Variant. For backward compatibility, the PageAsObj and PageFromName properties were added. The PageAsObj and PageFromName properties have the same signatures and occupy the same vtable slots as did the prior version of the Page property.
Example
As it applies to the Layer object.
This Microsoft Visual Basic for Applications (VBA) macro shows how to use the Page property to return a Page object from various other objects.
Public Sub Page_Example()
Dim vsoPage1 As Visio.Page
Dim vsoPage2 As Visio.Page
Dim vsoTempPage As Visio.Page
Dim vsoLayer1 As Visio.Layer
Dim vsoLayer2 As Visio.Layer
Dim vsoLayers1 As Visio.Layers
Dim vsoLayers2 As Visio.Layers
'Set the current page name to MyPage1.
ActivePage.Name = "MyPage1"
'Use the Page property to return the current
'Page object from the Window object.
Set vsoPage1 = ActiveWindow.Page
'Verify that the expected page was received.
Debug.Print "The active window contains: " & vsoPage1.Name
'Add a second page named MyPage2.
Set vsoPage2 = ActiveDocument.Pages.Add
vsoPage2.Name = "MyPage2"
'Get the Layers collection from each page.
Set vsoLayers1 = vsoPage1.Layers
Set vsoLayers2 = vsoPage2.Layers
'Create a layer for each of the Layers collections.
Set vsoLayer1 = vsoLayers1.Add("ExampleLayer1")
Set vsoLayer2 = vsoLayers2.Add("ExampleLayer2")
'Use the Page property to return the Page object
'from a Layers object.
Set vsoTempPage = vsoLayers1.Page
'Verify that the expected page was received.
Debug.Print " vsoLayers1 is from: " & vsoTempPage.Name
'Use the Page property to return the Page object
'from a Layer object.
Set vsoTempPage = vsoLayers2.Page
'Verify that the expected page was received.
Debug.Print " vsoLayers2 is from: " & vsoTempPage.Name
'Set the active window's page to "MyPage1."
ActiveWindow.Page = "MyPage1"
End Sub
Applies to | Layer object | Layers collection | Window object
See Also | Master property | Page object