![]() |
|
|
|
#1
|
||||
|
||||
|
The following should work for you
Code:
Select Case True
Case Chbx2 = True And Chbx3 = True And Chbx4 = True And Chbx5 = True And Chbx6 = True
FillBM "First", "CheckBox2, CheckBox3, CheckBox4, CheckBox5 and CheckBox6"
Case Chbx2 = True And Chbx3 = False And Chbx4 = True And Chbx5 = False And Chbx6 = True
FillBM "First", " CheckBox2, CheckBox4 and CheckBox6"
End Select
Code:
Public Sub FillBM(strbmName As String, strValue As String)
'Graham Mayor - https://www.gmayor.com
Dim oRng As Range
With ActiveDocument
On Error GoTo lbl_Exit
If .Bookmarks.Exists(strbmName) = True Then
Set oRng = .Bookmarks(strbmName).Range
oRng.Text = strValue
oRng.Bookmarks.Add strbmName
End If
End With
lbl_Exit:
Set oRng = Nothing
Exit Sub
End Sub
Code:
Public Sub FillCC(strCCTitle As String, strValue As String, bLock As Boolean)
'Graham Mayor - https://www.gmayor.com - Last updated - 03 Sep 2021
Dim oCC As ContentControl
On Error GoTo lbl_Exit
For Each oCC In ActiveDocument.ContentControls
If oCC.Title = strCCTitle Then
oCC.LockContents = False
oCC.Range.Text = strValue
oCC.LockContentControl = True
oCC.LockContents = bLock
Exit For
End If
Next oCC
lbl_Exit:
Set oCC = Nothing
Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| UserForm with checkboxes that hide/show bookmarked text in document | dohertym | Word VBA | 4 | 05-16-2022 09:48 PM |
Use VBA to create checkboxes and text boxes in Word
|
rotunda | Word VBA | 6 | 06-16-2021 03:13 PM |
| Macro-inserting text box | BLUEPUPIL | Word VBA | 14 | 04-16-2018 06:59 AM |
Inserting and rearranging text by inspecting existing text
|
rok123 | Word VBA | 9 | 02-05-2016 07:31 PM |
Mutually exclusive checkboxes with text
|
jt3writer | Word VBA | 2 | 01-21-2015 12:41 PM |