Templates/Macros

S

Sue

I've created a template document and want to run a macro
on exit from a form field. I've followed the instructions
for Word 2000, but get the message "this method or
property is not available because the object refers to a
protected area of the document." I wish to automatically
run the macro upon exiting the field as the help
instructions tell me I can do.

Can anyone help?

Thanks!
 
C

Charles Kenyon

The error message tells me that you are trying to work on something
protected by forms protection in your macro. In your macro you need to
unprotect the document before it reaches this point. Then after you've done
what you are trying to do, reprotect the document. I would suggest posting
the code of your macro in one of the vba newsgroups and asking for help if
this is troublesome. The macro for spellchecking protected forms on the MVP
website provides an example of a macro that unprotects the document, makes
changes, and then reprotects it.
--

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.
 
S

Sue

You are correct, I am trying to work on a protected
document. However, I did unprotect the form, prior to
creating the macro, as the instructions within Word has
advised. I with the macro to run upon exit of a protected
field. Within the Macro setup, I have that option. Here
are the steps I follow:

1. Open the document
2. Unprotect the form
3. Create the macro
4. Apply the macro to the field I wish to run it from
upon exiting.
5. Reprotect the form.
6. Resave the form.

Everything works fine until I actually try the form.

Any other suggestions? Or I am just doing something
incorrectly?

Thanks for the help!

Sue
 
C

Charles Kenyon

I'm sorry I was unclear. Your _macro_ must unprotect your form, run your
procedure, and then reprotect the form. Did you look at the spellchecking
macro on the MVP site? It does this. You could copy that part of the code
into your own macro.
--
See <url: http://www.mvps.org/word/FAQs/MacrosVBA/SpellcheckProtectDoc.htm>.


--

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.
 

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