Results 1 to 5 of 5

Thread: Locked Forms

  1. #1
    Star Lounger
    Join Date
    Jan 2001
    Location
    Vancouver, Washington, USA
    Posts
    79
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Locked Forms

    Text entered in a text box in a locked form disappears even after a save if the form is unlocked and then locked again.
    Word2000

  2. #2
    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: Locked Forms

    That's right. It does. Word has apparantly changed this in XP, finally!

    You can relock the form with the following VBA macro.

    Sub LockMyForm
    If ActiveDocument.ProtectionType = wdNoProtection Then
    ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
    End If
    End Sub

    See <A target="_blank" HREF=http://www.wopr.com/cgi-bin/w3t/showthreaded.pl?Cat=&Board=wrd&Number=46727&page=0 &view=collapsed&sb=5&o=0&part=> my separate post</A> for an Add-In that adds a command to do this.
    Hope this helps.
    Charles Kyle Kenyon
    Madison, Wisconsin

  3. #3
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: Locked Forms

    You could do it Charles' way or alternatively hijack Microsoft's use of the ProtectForms macro with your own which gives you the choice to wipe or not. I personally prefer this way as the user doesn't need to 'remember the other way' to get a sensible solution. If you place this macro in your Normal.dot or any template with Forms then it will override the normal way's of protecting the form. You may run into problems if individual sections are protected. I have never been bothered to code for that as I don't normally set files up that way anyway.
    <pre>Public Sub ProtectForm()
    ' Macro created 8/03/99 by Andrew Lockton
    'This macro stops the forms protection button from wiping the data in the fields
    ' when the document is protected. User is given an input choice.
    ' Overrides the built in ProtectForm command in word

    Dim Msg, Style, Title, Response

    If ActiveDocument.ProtectionType = wdAllowOnlyFormFields Then
    ActiveDocument.Unprotect

    Else
    Msg = "Do you want to empty the fields already typed?" ' Define message.
    Style = vbYesNo + vbDefaultButton2 ' Define buttons.
    Title = "Empty Fields" ' Define title.

    Response = MsgBox(Msg, Style, Title)

    If Response = vbYes Then ' User chose Yes.
    If ActiveDocument.ProtectionType = wdNoProtection Then
    ActiveDocument.Protect Type:=wdAllowOnlyFormFields, _
    NoReset:=False, Password:=""
    End If
    Else ' User chose No.
    If ActiveDocument.ProtectionType = wdNoProtection Then
    ActiveDocument.Protect Type:=wdAllowOnlyFormFields, _
    NoReset:=True, Password:=""
    End If
    End If
    End If</pre>

    Andrew Lockton, Chrysalis Design, Melbourne Australia

  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: Locked Forms

    Andrew,

    That's a good idea to give the choice- I should do the same myself.

    I quite often use unprotected sections, so I had to try something different. I tried to use the built-in dialogs, but I didn't have access to all the properties (There's some pretty flaky stuff around with the built-in dialogs).

    I came up with my own dialog boxes. I've attached what I was working on- though I had to put it on hold. I haven't put in the option to preserve or wipe out the fields- next step!
    Attached Files Attached Files
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

  5. #5
    Star Lounger
    Join Date
    Jan 2001
    Location
    Vancouver, Washington, USA
    Posts
    79
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Locked Forms

    I copied your Add-in to the Word Startup folder. Then I opened Word 2000, pressed Alt+F11 and attempted to open the form, but I got the "Object Locked" message. I get the same message when I attempt to see its Properties. Note: I did get a message about "signature" when I was orginally downloading your form.

    chrisl

Posting Permissions

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