closeing only active document

P

Peter KNAP

Hi.
how to write macro for closing only active document not all the word
application?
in F1 help I found st. like :
ActiveDocument.Close SaveChanges:=wdPromptToSaveChanges
but when user is asked whether he wants to save changes or not there is also
possibility to cancel and when this is done document is not closed. I would
like to manage to close active document without possibolity for cancelling
(just save or not).
regards
Peter.
 
D

Doug Robbins - Word MVP

ActiveDocument.Close wdDoNotSaveChanges

or

ActiveDocument.Close wdSaveChanges

Do not use the second one if the document has not been saved and you do not
want the user to be given the option to cancel.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
P

Peter KNAP

Thank you Doug.
it works well but after clicking the button for exit UserForm
ActiveDocument is closed but UserForm stays and user have to click one more
time. it is trivial but I would like to create perfectly working form.
I assume VBA give posibility to deal with it. can you help me?
peter

„Doug Robbins - Word MVP" napísal (napísala):
 
D

Doug Robbins - Word MVP

The final command in the Click button code should use the .Hide command to
hide the userform.

See the article "How to create a Userform" at:

http://word.mvps.org/FAQs/Userforms/CreateAUserForm.htm


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
P

Peter KNAP

of course, simple as that
I added hide command to all userforms I use except this one.
Thank you.

„Doug Robbins - Word MVP" napísal (napísala):
 

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