macros in protected docs

S

Steve Clark

Hi,

I have Word 2003 and am trying to get macros to run in a protected document.
I get the error "Can't run macro because document is protected" even though
my Security is at the lowest setting.

I don't know anything about VBA so I'm at a loss (and I don't even know if
VBA has anything to do with the solution). Thanks...
 
D

Dave Lett

Hi Steve,

Word has a couple levels of protection. When you set the security level to
low, then you are setting the security for the _application_. When an author
protects a document, then s/he is protecting the _document_. If you want to
run your macros on a protected document, then you can use something like the
following:

Dim iProType As Integer
iProType = ActiveDocument.ProtectionType
ActiveDocument.Unprotect
'''run your routine/macro
ActiveDocument.Protect Type:=iProType, NoReset:=True

HTH,
Dave
 
J

Jonathan West

Is the document protected for forms?

A large part of the Word object model doesn't work on a protected document.
If you need to make changes to protected parts of a document, you need to
temporarily unprotect it, make the changes, then protect it again.

--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 

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