Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #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
 



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 11:51 AM.


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