Reply
 
Thread Tools Display Modes
  #1   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 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   Report Post  
Posted to microsoft.public.word.newusers
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default 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   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.}




Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Newbie Question on on tables [email protected] Tables 10 December 6th 06 01:08 PM
Complete newbie question Peter Brown Mailmerge 1 June 16th 06 10:53 AM
NewBie Question 2 Please Help Tom Grassi New Users 2 September 9th 05 05:03 PM
newbie question; working with Word paxton Microsoft Word Help 2 February 2nd 05 05:10 PM
Newbie document question please Dudley Henriques New Users 4 January 9th 05 08:38 PM


All times are GMT +1. The time now is 08:43 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"