View Single Post
 
Old 06-09-2011, 11:54 AM
Welshgasman Welshgasman is offline Windows 7 32bit Office 2003
Novice
 
Join Date: Jun 2011
Posts: 26
Welshgasman is on a distinguished road
Default Does this help

I am a novice at VBA and I was looking to do something smiliar and found this method.

I wanted a dropdown to set the relevant checkbox. Initially I read that you cannot set checkbox values, but eventually found that you can and how from here from which I created the following code

Hope it helps.?

Code:
Function SetChkType()
Dim strType As String
Dim oFFld As FormFields
strType = ActiveDocument.FormFields("lstType").Result
Set oFFld = ActiveDocument.FormFields

' Initialise checkboxes to empty (False)

    oFFld("chkAnswer").CheckBox.Value = False
    oFFld("chkPhone").CheckBox.Value = False
    oFFld("chkVisit").CheckBox.Value = False
    oFFld("chkLetter").CheckBox.Value = False
    oFFld("chkRefer").CheckBox.Value = False
    oFFld("chkEmail").CheckBox.Value = False

' Now set the correct one to True

Select Case strType
    Case "A"
        oFFld("chkAnswer").CheckBox.Value = True
    Case "T"
        oFFld("chkPhone").CheckBox.Value = True
    Case "P"
        oFFld("chkVisit").CheckBox.Value = True
    Case "L"
        oFFld("chkLetter").CheckBox.Value = True
    Case "R"
        oFFld("chkRefer").CheckBox.Value = True
    Case "E"
        oFFld("chkEmail").CheckBox.Value = True
End Select
End Function
Reply With Quote