How can I run a macro on a protected Word document

M

Mayavi

Hi Experts,

I am writing a TCL application using tcom which opens up a number of word
documents, unlinks some fields in them and then zips them up.

These documents are protected before they reach me, so when I try to
call the Run Macro method from TCL, i get the error that says "Macro
cannot run on protected document"

I am new to Word and VB and tcom. Any ideas on how to unprotect the document
first using tcl? Or is there a way to use a password to unprotect the
document
before running the macro?

Any help appreciated

Newbie :)
 
O

old man

Hi,

This will unprotect a document that was protected without a password:

If ActiveDocument.ProtectionType <> wdNoProtection Then
ActiveDocument.Unprotect
End If

If you it is password protected and you know it (lets say the password is
Lock25 then:

If ActiveDocument.ProtectionType <> wdNoProtection Then
ActiveDocument.Unprotect Password:="Lock25"
End If

If you do not know the password there is no way through VBA to unlock it.
There are quite a few programs on the internet that will unlock Office files.

old man
 

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