Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-06-2017, 10:29 AM
warbird warbird is offline Content Control Option Button Oops Windows 7 64bit Content Control Option Button Oops Office 2010 64bit
Novice
Content Control Option Button Oops
 
Join Date: Jun 2015
Posts: 13
warbird is on a distinguished road
Default Content Control Option Button Oops

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
Reply With Quote
  #2  
Old 12-06-2017, 01:40 PM
macropod's Avatar
macropod macropod is offline Content Control Option Button Oops Windows 7 64bit Content Control Option Button Oops Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #3  
Old 12-06-2017, 02:36 PM
warbird warbird is offline Content Control Option Button Oops Windows 7 64bit Content Control Option Button Oops Office 2010 64bit
Novice
Content Control Option Button Oops
 
Join Date: Jun 2015
Posts: 13
warbird is on a distinguished road
Default

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...
Reply With Quote
  #4  
Old 12-06-2017, 02:45 PM
macropod's Avatar
macropod macropod is offline Content Control Option Button Oops Windows 7 64bit Content Control Option Button Oops Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #5  
Old 12-07-2017, 06:07 AM
warbird warbird is offline Content Control Option Button Oops Windows 7 64bit Content Control Option Button Oops Office 2010 64bit
Novice
Content Control Option Button Oops
 
Join Date: Jun 2015
Posts: 13
warbird is on a distinguished road
Default

I agree, but I'm coding an existing form. I can't make significant changes to the way it looks.
Reply With Quote
  #6  
Old 12-07-2017, 06:53 AM
warbird warbird is offline Content Control Option Button Oops Windows 7 64bit Content Control Option Button Oops Office 2010 64bit
Novice
Content Control Option Button Oops
 
Join Date: Jun 2015
Posts: 13
warbird is on a distinguished road
Default

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.
Reply With Quote
Reply

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
Content Control Option Button Oops Clicking the selected Content Control checkbox returns wrong control in vba event DougsGraphics Word VBA 2 06-24-2015 07:31 AM
Content Control Option Button Oops Option Button help ksigcajun Word VBA 1 01-15-2015 01:36 PM
Content Control Option Button Oops 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

Other Forums: Access Forums

All times are GMT -7. The time now is 04:10 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft