Visio2000: Sample Macro to Set a Drawing Page to Landscape Orientation (286217)



The information in this article 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("PageWidth")
   PageOriginalHeight = visPageSheet.Cells("PageHeight")

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

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

End Sub
				

REFERENCES

For additional information about how to use the sample code in this article, click the article number below to view the article in the Microsoft Knowledge Base:

277011 Visio2000: How to Run Sample Code from Knowledge Base Articles

For the latest information, hot topics, resources, downloads, and more for the Visio Developer, go to the following Microsoft Web site:

Modification Type:MinorLast Reviewed:10/11/2006
Keywords:kbdtacode kbhowto KB286217