Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.newusers
|
|||
|
|||
Newbie question - how can I run a macro on a protected document
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.} |
#2
Posted to microsoft.public.word.newusers
|
|||
|
|||
Newbie question - how can I run a macro on a protected document
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.} |
#3
Posted to microsoft.public.word.newusers
|
|||
|
|||
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.} |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Newbie Question on on tables | Tables | |||
Complete newbie question | Mailmerge | |||
NewBie Question 2 Please Help | New Users | |||
newbie question; working with Word | Microsoft Word Help | |||
Newbie document question please | New Users |