Results 1 to 5 of 5
  1. #1
    4 Star Lounger
    Join Date
    Apr 2001
    Posts
    482
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Protecting a section(s) (VBA Word 2000)

    I know how to protect a section using the Protect method, but I could not find any way to specify which sections of a multisection document you want to protect. Say I only want to protect section 1 and leave section 2 unprotected. The Protect method only seems to apply to the Document object (i.e. not the Sections collection).

    The good news is that it appears to protect whatever was protected previously if you selected the sections manually. This is a good workaround, I guess. But for future use, if I wanted to start with a document that had never been protected previously and select which section, is it possible to do that with VBA?

    Thanks!!
    Troy

  2. #2
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Protecting a section(s) (VBA Word 2000)

    Troy, I only have W97 here, and it only protects forms on a section by section basis, so
    ActiveDocument.Sections(2).ProtectedForForms = True
    is OK.

    Can you protect a single section of a W2k document with the menus?
    --Sam
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  3. #3
    4 Star Lounger
    Join Date
    Apr 2001
    Posts
    482
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Protecting a section(s) (VBA Word 2000)

    That method would work, except I need to be able to NOT reset field values and to specify a password. Both of those options are available with the Protect method, but neither seem to be available for the property you mentioned.

    Any other ideas?

    Thanks!!
    Troy

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

    Re: Protecting a section(s) (VBA Word 2000)

    I just tested this on Word 2000 by creating a simple document with two sections and a formfield in the second section.

    I issued the commands
    <pre>ActiveDocument.Sections(1).ProtectedForForm s = False
    ActiveDocument.Sections(2).ProtectedForForms = True
    </pre>

    At this point the document is NOT protected for forms. I have just told Word which sections should be protected later
    Then I typed
    <pre>ActiveDocument.Protect type:=wdAllowOnlyFormFields
    </pre>

    and now the second section was protected but the first one still allowed me to edit whatever I wanted.

    StuartR

  5. #5
    4 Star Lounger
    Join Date
    Apr 2001
    Posts
    482
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Protecting a section(s) (VBA Word 2000)

    Great idea!! That should do me!

    Troy

Posting Permissions

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