![]() |
|
#1
|
|||
|
|||
|
Hello I have 4 bookmarks on the activedocument. My bookmarks in activedocument is place in one line, but with 4 spaces in between bookmarks. In userform, if user selects just one of the bookmarks, (and leave the other 3 empty) how do I remove the spaces (on the activedocument) between each empty bookmarks? i.e.: if textbox2 is blank, i need to remove the bookmark and the 4 spaces after it in activedoc: or: if OptionButton1 = False i want bookmark and 4 spaces after this deleted. Thanks in advance. Code:
Private Sub CommandButton1_Click()
Dim text1 As Range
Dim text2 As Range
Dim optionbox As Range
Dim checkbox As Range
Set text1 = ActiveDocument.bookMarks("BMtext1").Range
Set text2 = ActiveDocument.bookMarks("BMtext2").Range
Set optionbox = ActiveDocument.bookMarks("BMoptionbox").Range
Set checkbox = ActiveDocument.bookMarks("BMcheckbox").Range
text1.Text = Me.TextBox1.Value
text2.Text = Me.TextBox2.Value
If OptionButton1.Value = True Then
optionbox.Text = Me.OptionButton1.Caption
ElseIf OptionButton1.Value = False Then
ActiveDocument.bookMarks("BMoptionBox").Delete
End If
If CheckBox1.Value = True Then
checkbox.Text = Me.CheckBox1.Caption
End If
End Sub
|
|
#2
|
|||
|
|||
|
I did not know I only needed ONE String and ONE Bookmark and just kept appending all data gathered (button caption, textbox, checkbox caption etc)
So I just created 1 bookmark and just kept appending to same string: partial code, where SmokingData0 is the string attached to one bookmark. So I just kept adding to same string. Code:
Dim SmokingData0 As Range
Set SmokingData0 = ActiveDocument.Bookmarks("BMsmokingData0").Range
If CBsmoking.Value = True Then
SmokingData0.Text = Me.CBsmoking.Caption & " "
End If
If CBcigarettes.Value = True Then
SmokingData0.Text = "Cigarette smoking since " & TBcigaretteSince.Text & ". "
If OBcigaretteStill.Value = True Then
SmokingData0.Text = SmokingData0.Text & "Currently smokes up to " & TBcigaretteStill.Text & ". "
ElseIf OBcigaretteStill.Value = False Then
If Not TBcigaretteStop.Text = "" Then
SmokingData0.Text = SmokingData0.Text & "Stopped since " & TBcigaretteStop.Text & ". "
End If
End If
End If
|
|
#3
|
|||
|
|||
|
Also I don't know how to mark this SOLVED!
|
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Removing Empty Brackets In Batch
|
Agog | Word VBA | 16 | 07-16-2018 05:39 AM |
How to find and replace random empty spaces in beginning of lines?
|
Pauliina | Word | 4 | 05-24-2018 10:01 PM |
removing spaces in cell
|
Tonykiwi | Excel | 4 | 11-06-2016 09:30 PM |
| Word-Help with removing unwanted spaces in text | greshoff | Word | 9 | 12-30-2011 03:24 PM |
double spaces in field ref (bookmarks)
|
GLENCOE | Word | 3 | 10-25-2011 07:35 AM |