Results 1 to 3 of 3

Thread: Word Protect Macro - Works in VB Editor but not from document

  1. #1

    Word Protect Macro - Works in VB Editor but not from document

    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,

  2. #2
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Sep 2005
    Seems to work fine here. What version of Word and how are you trying to run it from within Word.

    Visit my website:

  3. #3
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts