View Single Post
 
Old 08-08-2023, 05:05 AM
Formd Formd is offline Windows 7 32bit Office 2007
Advanced Beginner
 
Join Date: Feb 2015
Location: TX
Posts: 49
Formd is on a distinguished road
Default Inserting text from checkboxes

Hello,
Is there another way to write the codes I have below?
The idea is to insert the text shown in the text box including "and" if there are multiple entries.

If Me.Chbx2 = True And Me.Chbx3 = True And Me.Chbx4 = True And Me.Chbx5 = True And Me.Chbx6 = True Then
Selection.GoTo What:=wdGoToBookmark, Name:="First"
With ActiveDocument.Bookmarks
.DefaultSorting = wdSortByName
.ShowHidden = True
End With
Selection.TypeText Text:=" CheckBox2, "
Selection.TypeText Text:="CheckBox3, CheckBox4, CheckBox5 and CheckBox6"

OR if the below is my selection

If Me.Chbx2 = True And Me.Chbx3 = False And Me.Chbx4 = True And Me.Chbx5 = And Me.Chbx6 = True Then
Selection.GoTo What:=wdGoToBookmark, Name:="First"
With ActiveDocument.Bookmarks
.DefaultSorting = wdSortByName
.ShowHidden = True
End With
Selection.TypeText Text:=" CheckBox2, CheckBox4 and CheckBox6"


Thanks in advance.
Reply With Quote