Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1071
  • Last Modified:

Programmatic way to set page / print properties

I am interested in finding a way to programmatically set / change the page and/or print properties within a Visio 2003 drawing. Ideally, I would like to have three buttons:

- Print on a single 11x17 page
- Print on two 8.5x11 pages
- Print on a single 8.5x11 page

My drawings are set up for 11x17 in landscape orientation and are set to print across two 8.5x11 pages in portrait orientation. I would like users to be able to click a button that will automatically set the print settings according to how they want the drawing to render on paper. If this could also work in the Visio viewer, even better.
0
mburdick
Asked:
mburdick
1 Solution
 
mburdickAuthor Commented:
I figured out the code on my own by recording macros, editing them, and manipulating some of the variables that I need set. What I've come up with for code is listed below.



Sub PrintSingle11x17()
 
    Dim UndoScopeID1 As Long
    UndoScopeID1 = Application.BeginUndoScope("Page Setup")
    Application.ActivePage.Background = False
    Application.ActivePage.BackPage = ""
    Application.ActivePage.PageSheet.CellsSRC(visSectionObject, visRowPage, visPageWidth).FormulaU = "17 in"
    Application.ActivePage.PageSheet.CellsSRC(visSectionObject, visRowPage, visPageHeight).FormulaU = "11 in"
    Application.ActivePage.PageSheet.CellsSRC(visSectionObject, visRowPage, visPageDrawSizeType).FormulaU = "0"
    Application.ActivePage.PageSheet.CellsSRC(visSectionObject, visRowPrintProperties, visPrintPropertiesPagesX).FormulaU = "1"
    Application.ActivePage.PageSheet.CellsSRC(visSectionObject, visRowPrintProperties, visPrintPropertiesPageOrientation).FormulaU = "2"
    Application.ActivePage.PageSheet.CellsSRC(visSectionObject, visRowPrintProperties, visPrintPropertiesPaperKind).FormulaU = "17"
    Application.EndUndoScope UndoScopeID1, True
 
End Sub
 
Sub PrintSingle85x11()
 
    Dim UndoScopeID1 As Long
    UndoScopeID1 = Application.BeginUndoScope("Page Setup")
    Application.ActivePage.Background = False
    Application.ActivePage.BackPage = ""
    Application.ActivePage.PageSheet.CellsSRC(visSectionObject, visRowPage, visPageWidth).FormulaU = "16.76 in"
    Application.ActivePage.PageSheet.CellsSRC(visSectionObject, visRowPage, visPageHeight).FormulaU = "10.76 in"
    Application.ActivePage.PageSheet.CellsSRC(visSectionObject, visRowPrintProperties, visPrintPropertiesPagesX).FormulaU = "1"
    Application.ActivePage.PageSheet.CellsSRC(visSectionObject, visRowPrintProperties, visPrintPropertiesPageOrientation).FormulaU = "2"
    Application.ActivePage.PageSheet.CellsSRC(visSectionObject, visRowPage, visPageDrawSizeType).FormulaU = "1"
    Application.ActivePage.PageSheet.CellsSRC(visSectionObject, visRowPrintProperties, visPrintPropertiesPaperKind).FormulaU = "1"
    Application.EndUndoScope UndoScopeID1, True
 
End Sub
 
Sub Print11x17on85x11()
 
    Dim UndoScopeID1 As Long
    UndoScopeID1 = Application.BeginUndoScope("Page Setup")
    Application.ActivePage.Background = False
    Application.ActivePage.BackPage = ""
    Application.ActivePage.PageSheet.CellsSRC(visSectionObject, visRowPage, visPageWidth).FormulaU = "17 in"
    Application.ActivePage.PageSheet.CellsSRC(visSectionObject, visRowPage, visPageHeight).FormulaU = "11 in"
    Application.ActivePage.PageSheet.CellsSRC(visSectionObject, visRowPage, visPageDrawSizeType).FormulaU = "2"
    Application.ActivePage.PageSheet.CellsSRC(visSectionObject, visRowPrintProperties, visPrintPropertiesPagesX).FormulaU = "2"
    Application.ActivePage.PageSheet.CellsSRC(visSectionObject, visRowPrintProperties, visPrintPropertiesPageOrientation).FormulaU = "1"
    Application.EndUndoScope UndoScopeID1, True
 
End Sub

Open in new window

0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now