ActiveDocument.Close not working on exit from a Form Field in protected document

P

Paul

Hoping some kind person can help out...

I have a protected form to gather information. I have various VBA
routines in place to do validity checking and also to export the data
gathered to a text file. This all works fine. The final task is to
save the document/form and then close it.

I cannot find any way of accomplishing the close from VBA. I get a
Command Failed message box when using ActiveDocument.Close

Application.Quit works but is not ideal as the form user may have
other documents open at the same time.

Any ideas?

Paul

PS Using Word 2000 but needs to run on Word 97 and upwards.
 
D

Doug Robbins

Have you tried using

ActiveDocument.Close wdDoNotSaveChanges

I'm assuming that you have already saved the document with some earlier
code.

--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP
 
P

Paul

Thanks for your reply.

I have indeed tried this and it does not work.

The behavior is very simple to replicate. Create a new document with a
form field and attach a Sub to the Entry event with just the line
ActiveDocument.Close Protect the form and then click on the form
field.
You can put a second form field in place so you can try the same code
on the Exit event.

It seems as though the document cannot be closed from code triggered
by the Entry or Exit events of a Form Field.

Cheers

Paul
 

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