Is there an event I can tie this action to?

J

Janie

I want a routine that whenever the user prints the document, it always starts
printing from page 2. I know I can use a line such as:

Application.PrintOut Pages:="2-"

but ... what event can I tie this action to? I do not want to tie it to a
button. I'm looking for something intrinsic in the document ... but I can't
seem to find a suitable event. The ThisDocument events are limited (Open,
New, Close) and Class Events (DocumentBeforePrint, DocumentBeforeClose,
DocumentBeforeSave, DocumentChange, DocumentOpen) don't seem up to the task
either.

Bright ideas?
 
J

Jay Freedman

Janie said:
I want a routine that whenever the user prints the document, it
always starts printing from page 2. I know I can use a line such as:

Application.PrintOut Pages:="2-"

but ... what event can I tie this action to? I do not want to tie it
to a button. I'm looking for something intrinsic in the document ...
but I can't seem to find a suitable event. The ThisDocument events
are limited (Open, New, Close) and Class Events (DocumentBeforePrint,
DocumentBeforeClose, DocumentBeforeSave, DocumentChange,
DocumentOpen) don't seem up to the task either.

Bright ideas?

How about just intercepting the Print commands (there are two, FilePrint and
FilePrintDefault)? See
http://www.word.mvps.org/FAQs/MacrosVBA/InterceptSavePrint.htm.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
J

Janie

Interesting. But I still have to place the line ... in this case:

Dialogs(wdDialogFilePrint).Show

so what would fire this line? I think I still need an event, don't I? I
can't have this line just by itself. It needs to be part of a procedure.
And, if the Dialog does appear, how can I automatically populate the Pages:
portion of the dialog box? Everything is suspended while the dialog
displays. DoEvents doesn't seem to overcome this, either. If I place this
into the DocumentBeforePrint event, the document still prints in its
entirety, no matter what I enter.

I think I am at a brick wall.
 
J

Jay Freedman

Forget the events. Use these two procedures. As explained in the article I
already pointed to, these specific procedure names cause the macros to execute
instead of the built-in functions when the user activates the menu or toolbar
commands.

Sub FilePrint()
' Intercepts the File > Print command and
' Ctrl+P shortcut and defaults to only page 2
' to the end of the document.
' Place this only in the specific template
' used to create documents to which this
' restriction applies, NOT in Normal.dot.

Dim myDialog As Dialog
Set myDialog = Dialogs(wdDialogFilePrint)

With myDialog
.Range = wdPrintRangeOfPages
.Pages = "2-"
.Show
End With

Set myDialog = Nothing
End Sub

Sub FilePrintDefault()
' Intercepts the Quick Print button on the
' toolbar and defaults to only page 2
' to the end of the document.
' Place this only in the specific template
' used to create documents to which this
' restriction applies, NOT in Normal.dot.

ActiveDocument.PrintOut Range:=wdPrintRangeOfPages, Pages:="2-"
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top