Happy New Year everyone. I created a Word document that contains numerous ActiveX Checkboxes (50+) that I believe slows down the document upon opening. As I understand, Content Control Checkboxes is the better way to go. I'm therefore changing the Checkboxes over to Content Controls but I'm beginning to learn that programming actions is quite different and I'm at a road block. Here's a small sample of code for one set of actions that I can't get to work properly:
Code:
Private Sub Document_ContentControlOnEnter(ByVal ContentControl As ContentControl)
Application.ScreenUpdating = False
If (ContentControl.Title = "ccHW" And ContentControl.Checked = True) Then
Selection.GoTo What:=wdGoToBookmark, name:="HW"
SelectionShow 'Calls this subroutine
Me.lblTitle.ForeColor = wdColorRed
Else
Selection.GoTo What:=wdGoToBookmark, name:="HW"
SelectionHide 'Calls this subroutine
End If
If (ContentControl.Title = "ccCS" And ContentControl.Checked = True) Then
Selection.GoTo What:=wdGoToBookmark, name:="CS"
SelectionShow
Me.lblTitle.ForeColor = wdColorViolet
Else
Selection.GoTo What:=wdGoToBookmark, name:="CS"
SelectionHide
End If
End Sub
In that sample, I have 2 x Content Controls plus an ActiveX Label called lblTitle. If the user selects the Content Control called ccHW then a hidden bookmark is made visible and the Title colour changes; similarly if the user selects the Content Control ccCS a different hidden bookmark is made visible and the title colour changes.
With the ActiveX Controls, I used Select Case to nest the decision making & determine the CheckBox values, but I can't seem to do the same with Content Controls, I guess hence why my code above doesn't work too well.
What I'm looking to achieve is firstly convert all my ActiveX check boxes to Content Controls or to add the ActiveX Controls to a UserForm to speed up the document load time. Using the 2 x controls mentioned above, what I want to happen is:
If ccHW is true then display the ccHW bookmark content and colour the Label red.
If ccCS is true then display the ccHW bookmark content and colour the Label violet.
If both ccHW and ccCS are true, both bookmarks are visible & colour the label violet.
If neither ccHW or ccCS are true then both bookmarks are hidden and coloue the label blue (this last point isn't in my code above).
Someone's probably thinking, "What the...!!!!" at my attempt, but any points in the right direction is greatly appreciated.
Regards Corin.