Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Apr 2012
    Posts
    240
    Thanks
    3
    Thanked 24 Times in 24 Posts

    Macro to protect Word docm form

    I have a 2010 Word form that I have to unprotect in order for a macro to enter some data into some bookmarks.
    I can automate the unprotect okay, but when I try to protect it again with this,

    ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True

    It doesn't protect the document. I want to protect it with a blank password. It's for my wife's use, and she has no interest in hacking my macros, but she will screw up the form if it's left unprotected.

  2. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts
    Have you tried putting an empty password in the line?

    ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=""
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  3. The Following User Says Thank You to Andrew Lockton For This Useful Post:

    BigMac56 (2012-09-11)

  4. #3
    3 Star Lounger
    Join Date
    Apr 2012
    Posts
    240
    Thanks
    3
    Thanked 24 Times in 24 Posts
    Just tried it, still no go.

    In case it helps, I'm running the code from within a formfield, on exit. The sheet starts out protected and I use a dropdown box to select an item from a list. On exit (pressing tab to get to the next cell in the table) the macro populates 4 more cells based on the choice made, and then ends without turning protection back on.

    Thanks for trying!

  5. #4
    3 Star Lounger
    Join Date
    Apr 2012
    Posts
    240
    Thanks
    3
    Thanked 24 Times in 24 Posts
    Just found the problem, I was still within another procedure when I tried to protect the document. I moved the "protect" macro to after the "End Select" statement and it worked fine.

    Thanks Andrew!

Tags for this Thread

Posting Permissions

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