Results 1 to 6 of 6
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Sunrise, Florida
    Posts
    324
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Protect Report (Office 2K)

    My work requires me to create reports. After I'm done, I have to email my report to a higher-up. I suspect that my reports are being edited without my consent. To no avail I've tried to come up with a macro that will detect the name of the active document and, if the word "Report" is in any part of the name, will password-protect the document so that no changes can be made unless the protection is removed. I came up with the following but it doesn't work. You're still able to change it:

    If ActiveDocument.ProtectionType = wdNoProtection Then
    ActiveDocument.Protect Type:=wdAllowOnlyFormFields, Password:="123456"
    End If
    ActiveDocument.Save

    Any help appreciated. Thanks in advance!

  2. #2
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Protect Report (Office 2K)

    That should work. If your document has multiple sections then you may need to add

    <code> For i = 1 to ActiveDocument.Sections.Count
    ActiveDocument.Sections(i).ProtectedForForms = True
    Next i</code>

    StuartR

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Sunrise, Florida
    Posts
    324
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Protect Report (Office 2K)

    Just a little more help. Where in my code do I insert your code? Thanks, StuartR!

  4. #4
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Protect Report (Office 2K)

    At the beginning, or at least before you set the document protection.

    StuartR

  5. #5
    4 Star Lounger
    Join Date
    Dec 2003
    Location
    Zoetermeer, Zuid-Holland, Netherlands
    Posts
    559
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Protect Report (Office 2K)

    One other addition might be useful:

    ActiveDocument.Protect Type:=wdAllowOnlyFormFields, Password:="123456", NoReset:=True

    This prevents resetting of the FormFields and loss of data.

  6. #6
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Sunrise, Florida
    Posts
    324
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Protect Report (Office 2K)

    Thanks and Blessings!

Posting Permissions

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