PDA

View Full Version : Word Protect Macro - Works in VB Editor but not from document



patricus
02-01-2017, 06:35 PM
Hello, first post so apologies for any bloopers.

Using two macros to unlock and re-lock a document to EnforceStyleLock protection (limit formatting to permitted styles).
Unlock macro works fine from both VB editor and Word application.

Lock macro Works fine from within VB editor.
Soon as I try and run it from Word application get the "Argument not Optional" error message.

Sub DocLock()
ActiveDocument.Protect Type:=wdNoProtection, NoReset:=True, Password:="passwordstring", UseIRM:=False, EnforceStyleLock:=True
End Sub

Any thoughts greatly appreciated.

Kind regards,
patricus

gmaxey
02-02-2017, 05:39 AM
Seems to work fine here. What version of Word and how are you trying to run it from within Word.

patricus
02-02-2017, 03:52 PM
Hi Greg, thank you for taking the time to reply.
Just your confirmation that it worked for you made me re-examine the one element I hadn't even considered.
I tried re-assigning a different button on the QAT to the macro.
Soon as I did that it solved it and works. Hadn't considered that and wouldn't have without your reply.