Results 1 to 4 of 4
  1. #1
    New Lounger
    Join Date
    Dec 2008
    Location
    Mishawaka, Indiana, USA
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy

    I'm using the below logic to toggle in a document that the first page needs to be protected. This is done by using
    forward and backward buttons on a custom toolbar. The button works fine with the exception when protect is already
    on. I get an error (i.e. Run-time '4605': - The Protect method or property is not available because the document is
    already protected." This happens when the "Previous" button is pressed too many time to reach the first page (First
    page needs to be protected). My question is how can I check if a document page is already protected ? I believe that
    will solve the problem. Thanks ! ! !

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

  2. #2
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts
    [quote name='LHooker' post='766865' date='23-Mar-2009 18:21']My question is how can I check if a document page is already protected ?[/quote]
    If ActiveDocument.ProtectionType = wdNoProtection Then
    ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
    End If

  3. #3
    New Lounger
    Join Date
    Dec 2008
    Location
    Mishawaka, Indiana, USA
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    StuartR,

    Thanks ! ! ! How would I check to if a document page unprotected ? Change "NoReset" to "False" ?

    If ActiveDocument.ProtectionType = wdNoProtection Then
    ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=False
    End If

  4. #4
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts
    [quote name='LHooker' post='766875' date='23-Mar-2009 19:04']Thanks ! ! ! How would I check to if a document page unprotected ? Change "NoReset" to "False" ?[/quote]
    Word protection does NOT apply to pages, but to Sections. If you have a separate section for Page 1 of the document then you can use commands like
    ActiveDocument.Sections(1).ProtectedForForms = True
    ActiveDocument.Sections(2).ProtectedForForms = False
    or
    If ActiveDocument.Sections(1).ProtectedForForms then
    MSgBox "Section 1 is protected"
    Else
    MsgBox "Section 1 is not protected"
    End If

Posting Permissions

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