Intercept FilePrint & PrintPreview

C

Charles Kenyon

I'm trying to write procedures that intercept the FilePrint,
FilePrintDefault, & FilePrintPreview commands. I followed the directions on
the MVP FAQ page and got starter macros. The problem is that it works fine
for FilePrint & FilePrintDefault but doesn't seem to work with PrintPreview.

The procedure checks a table to see if anything has been entered in it. If
not, it hides the table. Then after printing or the preview it unhides the
table. This is because if I leave the table hidden (in a protected form)
Word zeros out any field within the table upon exiting the field.

The problem seems to be that Word unhides the table before displaying the
preview. My code is as follows:
Sub FilePrintPreview()
'
' FilePrintPreview Macro
' Displays full pages as they will be printed
'
HideTables
MsgBox "Tables hidden."
ActiveDocument.PrintPreview
ShowTables
MsgBox "Tables unhidden."
End Sub

TIA
--

Charles Kenyon

Word New User FAQ & Web Directory:
<URL: http://addbalance.com/word/index.htm>

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide)
<URL: http://addbalance.com/usersguide/index.htm>

See also the MVP FAQ: <URL: http://www.mvps.org/word/> which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
W

Word Heretic

G'day "Charles Kenyon" <[email protected]>,

Print Preview is a view mode. Thus you macro runs on after setting the
view. It does not asynchronously wait for the "close" print preview
button. Your best bet is to capture that close and re divert to it to
your needs I guess.


I'm trying to write procedures that intercept the FilePrint,
FilePrintDefault, & FilePrintPreview commands. I followed the directions on
the MVP FAQ page and got starter macros. The problem is that it works fine
for FilePrint & FilePrintDefault but doesn't seem to work with PrintPreview.

The procedure checks a table to see if anything has been entered in it. If
not, it hides the table. Then after printing or the preview it unhides the
table. This is because if I leave the table hidden (in a protected form)
Word zeros out any field within the table upon exiting the field.

The problem seems to be that Word unhides the table before displaying the
preview. My code is as follows:
Sub FilePrintPreview()
'
' FilePrintPreview Macro
' Displays full pages as they will be printed
'
HideTables
MsgBox "Tables hidden."
ActiveDocument.PrintPreview
ShowTables
MsgBox "Tables unhidden."
End Sub

TIA

Steve Hudson

Word Heretic, Sydney, Australia
Tricky stuff with Word or words for you.
wordheretic.com

If my answers r 2 terse, ask again or hassle an MVP,
at least they get recognition for it then.
Lengthy replies offlist require payment.
 

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