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

    Unlinking checkboxes (WinXP/Word2003)

    Interesting little quirk I've just discovered ... the template I'm working on has several sections and as each is completed, the form is forwarded to the next person to complete the next section. In order to ensure that the finished sections don't get changed by later users, it is unlinked and protected. Which works fine for textfields and dropdowns.

    However, it seems to ignore checkboxes! How do I unlink a checkbox, leaving an X, or an X in a box, to indicate the one that was selected and a blank or a blank box for the others?

    " 'Curiouser and curiouser', said Alice ..."
    Beryl M


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

    Re: Unlinking checkboxes (WinXP/Word2003)

    Here is a macro that will replace form check boxes with characters from the Wingdings font. It will run through the entire document. You can limit it to a specific section by changing ActiveDocument.FormFields to ActiveDocument.Sections(n).Range.FormFields where n is the index of the section.
    This version assumes that the document is protected, and reprotects it after processing the check boxes. Modify as needed.

    Sub UnlinkCheckBoxes()
    Dim ff As FormField
    ActiveDocument.Unprotect
    For Each ff In ActiveDocument.FormFields
    If ff.CheckBox.Valid Then
    If ff.CheckBox.Value = True Then
    ff.Range.InsertSymbol Font:="Wingdings", _
    CharacterNumber:=-3842, Unicode:=True
    Else
    ff.Range.InsertSymbol Font:="Wingdings", _
    CharacterNumber:=-3928, Unicode:=True
    End If
    End If
    Next ff
    ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
    End Sub

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

    Re: Unlinking checkboxes (WinXP/Word2003)

    Thanks, Hans - that's great! You're a genius!

    <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>
    Beryl M


  4. #4
    4 Star Lounger
    Join Date
    Dec 2003
    Location
    Zoetermeer, Zuid-Holland, Netherlands
    Posts
    559
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Unlinking checkboxes (WinXP/Word2003)

    > This version assumes that the document is protected

    That's why I always use the function IsProtected that I wrote. I never again have to wonder if a document is protected or not when I'm writing/editing code to manipulate it.

    <pre>Sub WhatEver()
    Dim blnProtected As Boolean

    blnProtected = IsProtected

    ' Your code

    If blnProtected Then ProtectionOn
    End Sub

    Public Function IsProtected() As Boolean
    IsProtected= False
    If ActiveDocument.ProtectionType <> wdNoProtection Then
    IsProtected= True
    ProtectionOff
    End If
    End Function


    Public Sub ProtectionOff(Optional blnNull As Boolean)
    ' In order to be used from different templates it must be Public
    ' Optional... prohibits visibility in Tools | Macro | Macro list)

    If Documents.Count < 1 Then Exit Sub

    ' I like screenupdating off when manipulating documents through code
    Application.ScreenUpdating = False
    If ActiveDocument.ProtectionType <> wdNoProtection Then
    ActiveDocument.Unprotect Password:="Secret"
    End If
    End Sub

    Public Sub ProtectionOn(Optional blnRO As Boolean)
    'In order to be used from different templates it must be Public
    'Optional... prohibits visibility in Tools | Macro | Macro list)

    If Documents.Count < 1 Then Exit Sub

    If ActiveDocument.ProtectionType = wdNoProtection Then
    ActiveDocument.Protect Password:="Secret", NoReset:=True
    End If
    Application.ScreenUpdating = True
    End Sub</pre>


Posting Permissions

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