I have a Word 2013 document with a number of tables. One table contains say 18 columns and 13 rows; each even numbered column contains an ActiveX CheckBox that references the cell to the left. When the CheckBox is selected, I want to simply format the cell to the left. I've used some basic coding, but with the number of rows and columns, I then have to change the value for each CheckBox. My code per CheckBox is as follows:
Code:
Application.ScreenUpdating = False
If cbHazChem.Value = True Then
ActiveDocument.Tables(24).Cell(3, 1).Select
Selection.Shading.BackgroundPatternColor = wdColorYellow
Else
ActiveDocument.Tables(24).Cell(3, 1).Select
Selection.Shading.BackgroundPatternColor = wdColorAutomatic
End If
Application.ScreenUpdating = False
I've used the Range.Offset property in Excel before and was wondering if there is something similar in Word VBA? i.e. so that I don't have to manually change the Cell reference for each and every CheckBox i.e. ...Cell(4,1)....Cell(5.1). I guess the code would need to know precisely where the Checkbox that was ticked is though, wouldn't it which might make the code for each CheckBox even longer?
Any thoughts?
Regards Corin.