![]() |
|
#1
|
|||
|
|||
|
I'm using this code to simulate the old option button group with content controls. It works but for one thing. If you miss-click the CC and the curser lands in the table cell the code doesn't run. It's then possible to mark more than one checkbox (which somewhat defeats the purpose). It's an obvious mistake and is easily corrected by clicking on another of the option buttons (assuming you click directly on the CC). The Is there something that can be added to the code to prevent this? Can the Table Cells be locked without effecting the CC's in it?
Code:
Private Sub Document_ContentControlOnEnter(ByVal oCC As ContentControl)
Application.ScreenUpdating = False
With ActiveDocument
On Error GoTo NoTally
With Selection
If oCC.Tag <> "RateDot" Then
GoTo NoTally
End If
If .Information(wdWithInTable) Then
Set oTbl = .Tables(1)
lCol = .Cells(1).ColumnIndex
End If
End With
If oTbl Is Nothing Then GoTo NoTally
Set oRow = oTbl.Rows(Selection.Cells(1).RowIndex)
With oRow
If .Range.ContentControls.Count < 5 Then GoTo NoTally
If oCC.Type = wdContentControlCheckBox Then
If oCC.Checked = True Then
For Each oCel In oRow.Cells
With oCel.Range
If .ContentControls.Count > 0 Then
If .ContentControls(1).Type = wdContentControlCheckBox Then
If oCel.ColumnIndex <> lCol Then
.ContentControls(1).Checked = False
End If
End If
End If
End With
Next
End If
Else
GoTo NoTally
End If
End With
NoTally:
Set oTbl = Nothing
End With
Application.ScreenUpdating = True
Exit Sub
End Sub
|
|
#2
|
||||
|
||||
|
Perhaps the approach I took in the links below will meet your needs.
https://www.msofficeforums.com/word-...html#post33489 https://www.msofficeforums.com/word-...tml#post107008
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#3
|
|||
|
|||
|
Thank for your prompt response. Performance evaluations are a common theme in this area. :-) Mine is too. I studied the first form extensively. Much of my code is modeled on it. Interestingly I am not able to duplicate the behavior on that form. That indicates to me that my answer is there somewhere. It may be a difference between executing the option buttons On Entry vs On Exit. I'll study the differences in the code and try a few variations and see where it leads...
|
|
#4
|
||||
|
||||
|
IMHO, where practicable, it is better to use dropdowns where only one option can be selected. That way, you don't need any of the coding complexities.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#5
|
|||
|
|||
|
I agree, but I'm coding an existing form. I can't make significant changes to the way it looks.
|
|
#6
|
|||
|
|||
|
However...
A representation of the image would probably suffice. A dropdown that offered the same result would probably work i.e. O O O O O (= 0) X O O O O (= 1) O X O O O (= 2) O O X O O (= 3) O O O X O (= 4) O O O O X (= 5) The above is relatively easy. Is there a way to do it with the Dots & Circles. It provides a clearer visual reference. |
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Check Box Content Control when checked users are presented with an option | cryder | Word | 0 | 01-07-2016 05:11 AM |
Clicking the selected Content Control checkbox returns wrong control in vba event
|
DougsGraphics | Word VBA | 2 | 06-24-2015 07:31 AM |
Option Button help
|
ksigcajun | Word VBA | 1 | 01-15-2015 01:36 PM |
Deleting a table from a content control -- preserving the content control
|
BrainSlugs83 | Word Tables | 8 | 11-14-2013 03:06 AM |
| Option Button ( ACtive X Control ) | aligahk06 | Excel | 0 | 11-03-2009 06:36 AM |