View Single Post
 
Old 09-04-2015, 02:01 PM
Eduardo Care Eduardo Care is offline Windows 8 Office 2010 64bit
Advanced Beginner
 
Join Date: Aug 2015
Location: Cali
Posts: 32
Eduardo Care is on a distinguished road
Default

Thanks for the code Guessed, but i should have been more specific, ill add a document with the checkboxes, and the other macro im using

Im already using another macro in my first 2 checkboxes, all i want its mark the "PV" box when any of the "Yes" boxes in my document its checked, i dont know if the macro it already has dont let me use your macro properly.


I need both of the macros, one to prevent both "yes" and "no" box to be checked and the other one to automatically check the "PV" box
Code:
Option Explicit

Sub ExclusiveCheckBoxes()
Dim strTemp As String
Dim oFF As FormField
Dim strGrpID As String
Dim strSeqID As String
Dim i As Long
Dim strSeqNext As String
  strTemp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 'Permits up to 26 checkboxes per group
  Set oFF = Selection.FormFields(1)
  If oFF.CheckBox.Value = True Then
    strGrpID = Left(oFF.Name, 8)
    strSeqID = UCase(Right(oFF.Name, 1))
  If strSeqID Like "[A-Z]" Then
    'Clear all GroupID ChkBoxes including the CB selected (ensure only one CB in group is selected).
    For i = 1 To Len(strTemp)
      strSeqNext = strGrpID & "_" & Mid(strTemp, i, 1)
      If ActiveDocument.Bookmarks.Exists(strSeqNext) Then
        ActiveDocument.FormFields(strSeqNext).CheckBox.Value = False
      End If
    Next i
    'Set the CB that was selected
    oFF.CheckBox.Value = True
    End If
  End If
lbl_Exit:
  Exit Sub
End Sub
Sub SetCheck()
  Dim bChecked As Boolean
  bChecked = False
  With ActiveDocument
    If .FormFields("CHK_1234_A").CheckBox.Value Then bChecked = True
    If .FormFields("CHK_2345_A").CheckBox.Value Then bChecked = True
    If .FormFields("Check1").CheckBox.Value Then bChecked = True
    .FormFields("Check1").CheckBox.Value = bChecked
  End With
End Sub
Attached Files
File Type: docm Risk Score.docm (22.3 KB, 11 views)
Reply With Quote