Microsoft KB Archive/286217

= Visio2000: Sample Macro to Set a Drawing Page to Landscape Orientation =

Article ID: 286217

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 Q286217



SUMMARY
This article contains a sample Microsoft Visual Basic for Applications macro (Sub procedure) to set a page's orientation to landscape.



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.

Sample Macro
Visio does not have a built-in method to set a page's orientation to landscape. To work around this limitation, switch the page width and page height of the page's ShapeSheet cells.

The following sample Visual Basic macro uses the PageSheet property of the Page object to switch the values: Public Sub PageLandscape

' Create two variables to hold the original cell values. Dim PageOriginalWidth As Single Dim PageOriginalHeight As Single

' Create and get a reference to the PageSheet of the page to be altered. ' NOTE: An error will occur if the ShapeSheet/PageSheet is the ' active window. Dim visPageSheet As Visio.Shape

Set visPageSheet = ActivePage.PageSheet

' Set the two variables equal to the original cell values. PageOriginalWidth = visPageSheet.Cells(&quot;PageWidth&quot;) PageOriginalHeight = visPageSheet.Cells(&quot;PageHeight&quot;)

' Switch the values in the page's cells. ActivePage.PageSheet.Cells(&quot;PageWidth&quot;) = PageOriginalHeight ActivePage.PageSheet.Cells(&quot;PageHeight&quot;) = PageOriginalWidth

' Set the printer orientation to landscape if needed. ActiveDocument.PrintLandscape = True

End Sub

