Set Paper and Page Size and Ruler and Grid Co-Ordinates using VBA – Microsoft Visio 2010

Sub PageLayout_to_A3()

 Dim pg_Page As Page
 
 'Set ActiveDocument = ThisDocument
 
 For Each pg_Page In ThisDocument.Pages
 
 With pg_Page.PageSheet
 
 'Page Setup
 'Page Setup\Print Setup\Printer Paper
 .CellsSRC(visSectionObject, _
 visRowPrintProperties, _
 visPrintPropertiesPaperKind) = visPaperSizeA3
 
 'Page Setup\Print Setup\Printer Paper\Margins
 .CellsSRC(visSectionObject, _
 visRowPrintProperties, _
 visPrintPropertiesTopMargin).FormulaU = "10 mm"
 
 .CellsSRC(visSectionObject, _
 visRowPrintProperties, _
 visPrintPropertiesLeftMargin).FormulaU = "10 mm"
 
 .CellsSRC(visSectionObject, _
 visRowPrintProperties, _
 visPrintPropertiesRightMargin).FormulaU = "10 mm"
 
 .CellsSRC(visSectionObject, _
 visRowPrintProperties, _
 visPrintPropertiesBottomMargin).FormulaU = "10 mm"
 
 'Page Setup\Print Setup\Print Zoom
 .CellsSRC(visSectionObject, _
 visRowPrintProperties, _
 visPrintPropertiesOnPage) = False
 
 .CellsSRC(visSectionObject, _
 visRowPrintProperties, _
 visPrintPropertiesScaleX) = 1
 
 'Page Setup\Page Size
 .CellsSRC(visSectionObject, _
 visRowPage, _
 visPageWidth).FormulaU = "420 mm"
 
 .CellsSRC(visSectionObject, _
 visRowPage, _
 visPageHeight).FormulaU = "297 mm"
 
 .CellsSRC(visSectionObject, _
 visRowPage, _
 visPageDrawResizeType) = 2
 
 .CellsSRC(visSectionObject, _
 visRowPage, _
 visPageDrawSizeType) = 3
 
 'Ruler & Grid
 ' Row 1 (X)
 .CellsSRC(visSectionObject, _
 visRowRulerGrid, _
 visXRulerOrigin).FormulaU = "10 mm"
 
 .CellsSRC(visSectionObject, _
 visRowRulerGrid, _
 visXGridOrigin).FormulaU = "10 mm"
 
 .CellsSRC(visSectionObject, _
 visRowRulerGrid, _
 visXGridSpacing).FormulaU = "2.5 mm"
 
 ' Row 2 (X)
 .CellsSRC(visSectionObject, _
 visRowRulerGrid, _
 visYRulerOrigin).FormulaU = "10 mm"
 
 .CellsSRC(visSectionObject, _
 visRowRulerGrid, _
 visYGridOrigin).FormulaU = "10 mm"
 
 .CellsSRC(visSectionObject, _
 visRowRulerGrid, _
 visYGridSpacing).FormulaU = "10 mm"
 
 ' Row 3 (X)
 .CellsSRC(visSectionObject, _
 visRowRulerGrid, _
 visXGridDensity) = 0
 
 ' Row 4 (X)
 .CellsSRC(visSectionObject, _
 visRowRulerGrid, _
 visYGridDensity) = 0
 
 End With
 
Next pg_Page

End Sub
Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s