View Single Post
  #3   Report Post  
Posted to microsoft.public.word.newusers
Mayavi Mayavi is offline
external usenet poster
 
Posts: 2
Default Newbie question - how can I run a macro on a protected documen

Thanks Graham! I assumed that the default password would be assumed to be ""
if it wasn't explicitly mentioned.

I added your code and it works now. i really appreciate the help.

Mayavi

"Graham Mayor" wrote:

You will need to add the password if any between the quotes - then

Dim bProtected As Boolean
'Unprotect the file
If ActiveDocument.ProtectionType wdNoProtection Then
bProtected = True
ActiveDocument.Unprotect Password:=""

End If

'Run your code

'Reprotect the document.
If bProtected = True Then
ActiveDocument.Protect _
Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=""
End If


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Mayavi wrote:
Hi, I am using tcl with tcom to process some Word files, search for
keywords, etc. I need to run a macro to unlink some fields. How can
I run this macro and unprotect the document automagically if the
document is sent to me protected?

I can open the document and see the contents, but I cannot run
the macro.

Thanks for any help! This is the error I get:

tcom::handle0x01439F60

% $::doc Run Macro1
0x80020003 {This method or property is not available because the
document is a p
rotected document.}