Home |
Search |
Today's Posts |
#1
|
|||
|
|||
Unprotect document
Is there a reported probelm with the Unprotect vba command? The following
code is from a recorded maco: (ok, it's silly because it locks and unlocks the document in the same step, but I was experimenting). ActiveDocument.Protect Password:="password", NoReset:=False, Type:= _ wdAllowOnlyComments, UseIRM:=False, EnforceStyleLock:=False ActiveDocument.Unprotect While recording, it produced the input box, requesting the password, as expected. But when I go into vb editor an "Run" the routine, it produces the message: Runtime error '5485' The password is incorrect. The input box never appeared requesting the password. Debug shows a problem with "ActiveDocument.Unprotect" This code was written by the recorder! |
#2
|
|||
|
|||
On Fri, 18 Feb 2005 14:01:01 -0800, martin
wrote: Is there a reported probelm with the Unprotect vba command? The following code is from a recorded maco: (ok, it's silly because it locks and unlocks the document in the same step, but I was experimenting). ActiveDocument.Protect Password:="password", NoReset:=False, Type:= _ wdAllowOnlyComments, UseIRM:=False, EnforceStyleLock:=False ActiveDocument.Unprotect While recording, it produced the input box, requesting the password, as expected. But when I go into vb editor an "Run" the routine, it produces the message: Runtime error '5485' The password is incorrect. The input box never appeared requesting the password. Debug shows a problem with "ActiveDocument.Unprotect" This code was written by the recorder! Just because a macro is recorded by the recorder does *not* mean that it's correct or will work without errors. There are a number of cases in which that is not true. If you know that the document protection is passworded, you have to edit the recorded macro to include the password in the Unprotect command. The Help topic on that command includes this example: If ActiveDocument.ProtectionType wdNoProtection Then ActiveDocument.Unprotect Password:=strPassword End If (You have to supply the value of the variable strPassword in some way, either as a constant stored in the macro or by using an InputBox statement to have the user type it in.) -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Can you save individual document pages as seperate word files? | Mailmerge | |||
How do I unprotect a document if I can't press the unprotect butt. | Microsoft Word Help | |||
unprotect document option is grayed out - cannot unprotect? | Microsoft Word Help | |||
Newbie document question please | New Users | |||
Document object in protected form | Tables |