Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Apr 2002
    Location
    Sussex, England
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Locking Text fields in forms (Office 2000)

    Does anyone know if there is a way to lock off text form fields that have had data entered in automatically on closing a document whilst at the same time leaving those fields that are still empty of data available for completion when the form is next opened? I am trying to create a form that will allow text fields to be filled in as on a form and minutes to be added and once added I want to lock those entries so they cannot be changed but I want to allow the future completion of those fields that have not been completed and also allow additional minutes to be added? Just locking off the form fields prevents all fields from subsequent completion. Any help or pointers would be gratefully appreciated. Simon

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Locking Text fields in forms (Office 2000)

    Hello Simon,

    You can handle this in the OnClose event of the document or template:

    Private Sub Document_Close()
    Dim ff As FormField
    ' Step through form fields
    For Each ff In ActiveDocument.FormFields
    ' Get text from form field
    If ff.Result <> "" Then
    ' If user entered something, lock it
    ff.Enabled = False
    End If
    Next ff
    End Sub

    In case you don't know where to enter this code:
    <UL><LI>Open the document or template
    <LI>Switch to the Visual Basic editor (Tools/Macro/Visual Basic editor or Alt+F11)
    <LI>You should see the Project Explorer: a window titled Project - something resembling the left hand panel of Windows Explorer. If not, select View/Project Explorer
    <LI>Find your document or template and expand it until you see ThisDocument
    <LI>Double click ThisDocument; you should see a code window
    <LI>Enter the macro - you should be able to copy and paste it from this post.
    <LI>Return to Word and save the document or template.[/list]HTH, Hans

  3. #3
    New Lounger
    Join Date
    Apr 2002
    Location
    Sussex, England
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Locking Text fields in forms (Office 2000)

    Brilliant! Thanks very much for a prompt response - it's just what I needed. It's simple when you know how <img src=/S/bravo.gif border=0 alt=bravo width=16 height=30>
    Simon

Posting Permissions

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