ClosePreview doesn't fire when the user clicks the X to close the window

R

Robert

Hi all.
In Word 97 when the user closed the print Preview window
Word would also close. In Office XP the user closes the
window and they are taken back to the main Word window.

Not wanting that to happen, I am running VBA in the
document to close word in the ClosePreview method.

Problem: The ClosePreview method doesn't fire when the
user clicks the X to close the print preview window. If
they click the close button (the one in the middle of the
window) it fires. Any ideas why that is?

What I need to be able to do is display the document from
VB6 to the user in print preview mode. Then when the user
is done looking at it and they click close (either place)
and word will close not giving the user a chance to mess
(in any way) with the document.

Any help is greatly appreciated.
R.
 
S

Suzanne S. Barnhill

I wouldn't have believed it till I tried it. It is entirely counterintuitive
to have the X close the window and not the document. Someone was asleep at
the switch on that one!

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://www.mvps.org/word
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
S

Shauna Kelly

Hi Robert

If your aim is to prevent changes being made to the document, then restricting a user to PrintPreview won't necessarily meet your
ends. The user could still click the Magnifier button, and can then edit the document from within the Print Preview view.

If you were happy to let the user make changes, but prevent the user from saving those changes, then you could intercept all the
FileSave* commands with code of your own that simply closed (but did not save) the file. See
http://www.mvps.org/word/FAQs/MacrosVBA/InterceptSavePrint.htm for more information.

Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
Melbourne, Australia
 
R

Robert Bradford

You are my hero. That worked exactly as I needed it to.

Thank you so much for your help.

Robert
-----Original Message-----
Hi Robert

ClosePreview seems to be entirely shaky. For example, it
doesn't fire when you use Escape to exit Print Preview.
In any case, the behaviour seems to depend on whether
Word is using SDI or MDI (info at
http://www.mvps.org/word/FAQs/Customization/SDIMDI.htm).

If you set Word so that it does not show each document
in the taskbar then, when the user is in Print Preview
and clicks the X, Word
closes (assuming no changes have been made to any open documents).

So, you could call print preview as follows:

Application.ShowWindowsInTaskbar = False
ActiveDocument.PrintPreview

You won't then need to trap ClosePreview, and the
application will work as it did in Word 97.
 

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