Changing the drawing layout from Portrait to Landscape or Landscape to Portrait is allot different in Visio then other Office Apps. Same for changing the drawing size too. Its objects are organized differently and a bit burried down the object heirarchy.
Visio 2003 VBA Code Example:
VB Code:
Option Explicit 'Behind ThisDocument 'Note: Assumes current open drawing is "Drawing1.vsd" Private Sub ChangeLayout() Application.Documents("Drawing1.vsd").Pages(1).PageSheet.CellsSRC(visSectionObject, _ visRowPrintProperties, visPrintPropertiesPageOrientation).FormulaU = "2" End Sub Private Sub ChangePageSize(ByVal strWidth As String, ByVal strHeight As String) Application.Documents("Drawing1.vsd").Pages(1).PageSheet.CellsSRC(visSectionObject, _ visRowPage, visPageWidth).FormulaU = "11 in" Application.Documents("Drawing1.vsd").Pages(1).PageSheet.CellsSRC(visSectionObject, _ visRowPage, visPageHeight).FormulaU = "8.5 in" End SubVB Code:
'Example Usage: Private Sub Command1_Click() ChangeLayout End Sub Private Sub Command2_Click() ChangePageSize "11 in", 8.5 in" End Sub





Reply With Quote