Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I print "current page" using VBA?

Status
Not open for further replies.

Alcedes

Technical User
Mar 25, 2008
46
US
I am trying to create a button that i can place on certain pages that the user can click to print out the page they are viewing.

This is a lot harder than orignally expected apparently.

I have tried using
ActiveDocument.PrintOut PrintRange:=visPrintCurrentPage, PrinterName:="XXXXXXXXX"

Sadly, this only works if I want to print page 1.

I have tried using

activedocument.printout printrange:=activepage.index

i have tried every thing i can think of.

A little help on this one would be great!
 
The first one will work, but you must make the page you want to print the active page.

John... Visio MVP - Visio.MVPs.org
 
I resolved that issue with this bit of code.

On Error GoTo 10
Dim UndoScopeID1 As Long
UndoScopeID1 = Application.BeginUndoScope("Page Setup")
Application.ActivePage.Background = False
Application.ActivePage.PageSheet.CellsSRC(visSectionObject, visRowPrintProperties, visPrintPropertiesOnPage).FormulaU = "1"
Application.EndUndoScope UndoScopeID1, True
Application.ActiveDocument.PrintOut visPrintFromTo, Application.ActivePage.Index, Application.ActivePage.Index, , , , , 1
Exit Sub
10
Whoops = MsgBox("An error has occured!", vbCritical + vbOKOnly)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top