Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2004

Tip: Looking for answers? Try searching our database.

Using AUTOEXIT

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Steve Wylie - 04 Nov 2004 18:00 GMT
We're having some problems with our network at the moment.  One of the
new "features" is that sometimes, when you close a document in Word,
Word also exits completely as well.  I wanted to put an AutoExit macro
on everyone's machines to ask "You are about to quit Word - is this
okay?" [Yes/No] whenever Word tries to exit.  If they click Yes, Word
will continue to exit; if they click No, Word will not exit and will
just sit there with a blank "gray" screen.

If Word macros were programmed in Javascript I could do something like
ONEXIT="Return MsgBox()" and I could have Msgbox return FALSE (which
would cancel the exit procedure) or TRUE (which would exit as normal).

How do I do the same thing in VBA?  Is there a way to get the macro to
cancel the exit procedure in its tracks?

Steve Wylie
Jay Freedman - 04 Nov 2004 20:37 GMT
Hi Steve,

See http://word.mvps.org/FAQs/MacrosVBA/PseudoBeforeClose.htm.

Signature

Regards,
Jay Freedman
Microsoft Word MVP          FAQ: http://word.mvps.org

> We're having some problems with our network at the moment.  One of the
> new "features" is that sometimes, when you close a document in Word,
[quoted text clipped - 12 lines]
>
> Steve Wylie
Steve Wylie - 04 Nov 2004 21:11 GMT
No, that's not it I'm afraid.  This affect closing the document - I want a
macro that will halt the Exiting of the application completely.  So far I
have come up with:

Sub AutoExit()

response = MsgBox("Do you want to quit Word?", vbYesNo)
If response = vbYes Then Application.Quit

End Sub

However, I need something just before the End Sub to halt the exiting of
Word.  At the moment it quits anyway.

Steve Wylie
Jay Freedman - 07 Nov 2004 03:02 GMT
Hi Steve,

I see your point. Neither AutoExit nor the application event handler
oApp_Quit (see http://word.mvps.org/FAQs/MacrosVBA/AppClassEvents.htm)
offers a Cancel parameter to stop the shutdown.

However, a userform's QueryClose event handler does have such a
parameter, so some clever folks have figured out that they can run a
dummy userform which, if it refuses to close, prevents the whole app
from shutting down. Here's a discussion of the technique in Access,
but something similar should work in Word:
http://dbforums.com/t362717.html

--
Regards,
Jay Freedman
Microsoft Word MVP         FAQ: http://word.mvps.org

>No, that's not it I'm afraid.  This affect closing the document - I want a
>macro that will halt the Exiting of the application completely.  So far I
[quoted text clipped - 11 lines]
>
>Steve Wylie
Steve Wylie - 07 Nov 2004 16:32 GMT
Hmm.  The Access solution is a bit too advanced for me, but it's given me an
idea about "forcing" Word to notify a user on shutdown.

If Normal.dot is changed (or thinks it's been changed) during a session,
there is a Word option to prompt about saving Normal.dot when Word closes.

What I need is a "transparent" way of changing/unchanging Normal.dot when
Word starts up, so a user can be told if they get the message and did not
intend to close Word down, they could just click Cancel and Word will not
shut down.

But how could I arrange for this to happen so the user would not have to do
anything themselves on startup?  I don't really want them going into the VBA
editor and manually changing some macro text or other to force the
Normal.dot to change...

Steve Wylie
Jonathan West - 07 Nov 2004 16:41 GMT
> Hmm.  The Access solution is a bit too advanced for me, but it's given me
> an
[quoted text clipped - 14 lines]
> editor and manually changing some macro text or other to force the
> Normal.dot to change...

You don't need to change normal.dot, you just need to kid Word into
believing it has been changed. This will do the trick

   NormalTemplate.Saved = False

To make Word think that normal.dot hasn't been changed, do this

   NormalTemplate.Saved = True

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup

Steve Wylie - 08 Nov 2004 18:29 GMT
Well, that will certainly work - thanks.  I'll stick that in an AUTOEXEC
macro.

Steve
Steve Wylie - 04 Nov 2004 21:33 GMT
I have also tried replacing the FileExit command with my own macro command:

Sub FileExit()

response = MsgBox("Do you want to quit Word?", vbYesNo)
If response = vbYes Then WordBasic.FileExit

End Sub

... but this only works with the user goes File/Exit on the menus.  It
doesn't even work when they manually close Word by clicking on the X in the
top right hand corner of the window, much less when my network fault forces
Word to close.

Steve

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.