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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Print Specific Page of Word Doc

Status
Not open for further replies.

ohmbru

Technical User
Jul 13, 2001
161
US
I want to print a specific page of a Word document using VBA to interrupt the normal print command. When the user clicks the print button, I need to print the document in this order:

Page 1
Page 2
Page 1
Page 2
Page 2

Can someone point me in the right direction?



Brian
 
Hi Brian,

You can intercept Print requests (from the menu or via Ctrl+p) simply by creating a procedure called FilePrint in a standard code module in the document or its template - in this procedure you can do what you want.

To intercept the print button on the toolbar you need to assign your procedure name to the OnAction property of the button - this is probably best done on document open (but that might depend on circumstances) - post back if you need more help with this.

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at [url=http://www.vbaexpress.
 
as in:

Code:
Sub Document_Open()
' resets Print button to myPrint sub
CommandBars("standard").Controls.Item("Print").OnAction = "myPrint"
End Sub

Sub FilePrint()
' overrides File/Print menu & calls myPrint sub
Call myPrint
End Sub

Sub myPrint()
    Application.PrintOut FileName:="", Range:=wdPrintRangeOfPages, Item:= _
        wdPrintDocumentContent, Copies:=1, Pages:="1,2,1,2,2"
End Sub

but maybe just put myPrint sub as button on toolbar, prints as you want. leave other printing things alone?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top