Results 1 to 12 of 12
  1. #1
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Protecting a document for forms (all)

    Hi,

    I've had a common problem in the past- when I have a document for forms, unprotect it, then reprotect it, the form fields get reset. This is a real pita for our users.

    I decided to hijack the Word commands- but found that the built-in dialog boxes (choosing the protection type, choosing sections to protect, and entering a password) were not completely documented- or in one case, documented incorrectly.

    So I built my own forms to do it. I'd certainly appreciate any feedback on this.

    Because there's custom forms, I have to attach the document, rather than just include code.
    Attached Files Attached Files
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

  2. #2
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Protecting a document for forms (all)

    I had this problem too - the following is what I now use to fix it (courtesy of the lounge). Unfortunately it was a while back and I can't remember any details of how it works, except that if placed in normal.dot (or template in startup directory) it does the job!

    <pre>Sub ProtectForm() 'If placed in normal, replaces Protect Form button
    If ActiveDocument.ProtectionType = wdNoProtection Then
    ActiveDocument.Protect Type:=wdAllowOnlyFormFields, noreset:=True
    Else
    ActiveDocument.Unprotect Password:=""
    End If
    End Sub

    Sub ToolsProtectUnprotectDocument1() 'if placed in normal, replaces
    'Tools
    Beryl M


  3. #3
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Protecting a document for forms (all)

    Hi Geoff:

    Beryl's got the answer. I think they came from the Microsoft KB Article:
    <A target="_blank" HREF=http://support.microsoft.com/support/kb/articles/Q191/0/28.ASP>Q191028 - WD2000: How to Retain Information Typed into a Form Field When You Protect a Form</A>

    Hope this helps.

  4. #4
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Protecting a document for forms (all)

    Beryl,

    Sorry for the delay in the response.

    This doesn't quite do all I wanted it to do.

    What I needed was to have a completely transparent way of protecting, which behaved exactly as the built-in way- allowing forms to be protected for tracked changes or comments as well as for forms; to allow sections to be protected, and passwords to be used.

    The help for the built-in dialog box wdDialogToolsProtectDocument gives me the arguments for DocumentPassword, NoReset and Type. Regardless of whether I select forms, comments or changes, the type is still 503- so I have no way of finding the protection type selected- given the "help".

    It was some while back when I worked on this- I also seem to remember that there was one of the values from the built-in dialog box which did not work as documented. This is why I chose to go for recreating the dialog boxes as user forms.

    Thanks for the input.
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

  5. #5
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Protecting a document for forms (all)

    Thanks Phil.

    I checked out the KB article, hoping to find a little more. As I mentioned to Beryl, this didn't quite do the job of allowing other protection types.

    I thought it a little sloppy of MS to use a number rather than a named constant in the protect:
    ActiveDocument.Protect Password:=pDoc.DocumentPassword, _
    NoReset:=True, Type:=2

    Rather than

    ActiveDocument.Protect Password:=pDoc.DocumentPassword, _
    NoReset:=True, Type:=wdProtectForForms

    Even allowing for protection of forms only, the MS code omits the confirmation of password- perhaps because there's no dialog box for confirmation of password.

    And when protecting for sections, the dialog box arguments for wdDialogToolsProtectSection (Protect, Section) do not allow me to determine which sections have been checked.

    I suspect these arguments are available somewhere, that the fault is just in the limited documentation rather than in the inability of the dialog boxes to do their job. If there is a way to access those properties, I'd love to know. But it looks as if the <A target="_blank" HREF=http://www.microsoft.com/Office/techinfo/productdoc/2002/en/word/vbawd10/wohowDialogArguments.htm>XP built-in dialog info</A> gives me no further info.

    Thanks for the help, and for pointing me at the KB article.
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

  6. #6
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Protecting a document for forms (all)

    I've had some correspondence with Dave Rado from the <A target="_blank" HREF=http://www.mvps.org/word/>mvps site</A> on this. The result is FAR more elegant than my solution posted here.

    Check out <A target="_blank" HREF=http://www.mvps.org/word/FAQs/MacrosVBA/TurnFmFlfResetOff.htm>How to change the behaviour of Word's document protection, so users
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

  7. #7
    Silver Lounger Charles Kenyon's Avatar
    Join Date
    Jan 2001
    Location
    Sun Prairie, Wisconsin, Wisconsin, USA
    Posts
    2,049
    Thanks
    124
    Thanked 119 Times in 116 Posts

    Re: Protecting a document for forms (all)

    I liked this enough to install it in my personal global template. Thanks!
    Charles Kyle Kenyon
    Madison, Wisconsin

  8. #8
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Protecting a document for forms (all)

    Charles,

    Ibby did well.

    Another gotcha still not fixed.

    If you have a doc with data, and print it, with the "update fields" options (tools, option, print options) set, the contents of the fields get set. It does happen- it has happened to our users a few times (though they tend to unprotect to spell check- so maybe it won't be a problem now).

    Keep an eye on the MVPS site.
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

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

    Re: Protecting a document for forms (all)

    The only way I found to deal with "Update Fields" resetting all the form fields was to create a Macro that replaces all form fields with their current contents. This worked well for a form that I sent out to other people that didn't need protecting after they had returned it.

    StuartR

  10. #10
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Protecting a document for forms (all)

    The technique I've used is to intercept the print commands, and if the document has form fields and is not protected, protect before printing, then unprotect.
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

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

    Re: Protecting a document for forms (all)

    If we are going to be intercepting commands then it might be better to intercept the call to ActiveDocument.Fields.Update and replace it with a Macro that updates all fields that aren't form fields.

    StuartR

  12. #12
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Protecting a document for forms (all)

    activedocument.fields.unlink in the document_new sub of the template being used works well *as long as* you only need to fill in the fields once - no good if the fields are needed later of course ...
    Beryl M


Posting Permissions

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