Hi Bigfoot17,
i'm sorry, other attempts didn't work,
and sure there are many ways of improvement and streamlining:
Sub CommandButton4_Click()
Dim sc2 As String
Dim rTmp As Range
Set rTmp = Selection.Range
sc2 = Chr(10) & "This is a test of the Emergency Broadcast " _
& TextBox1 & " some more text" & Chr(10)
Selection.Collapse
Selection.Bookmarks.Add "Test"
Selection.Bookmarks("Test").Range.Text = sc2
Selection.Bookmarks.Add "Test1"
rTmp.start = ActiveDocument.Bookmarks("Test").start
rTmp.End = ActiveDocument.Bookmarks("Test1").End
With rTmp.Find
.Text = "test"
If .Execute Then
rTmp.Font.Underline = wdUnderlineSingle
End If
End With
rTmp.start = ActiveDocument.Bookmarks("Test").start
rTmp.End = ActiveDocument.Bookmarks("Test1").End
With rTmp.Find
.Text = "Emergency"
If .Execute Then
rTmp.Font.Underline = wdUnderlineSingle
End If
End With
rTmp.start = ActiveDocument.Bookmarks("Test").start
rTmp.End = ActiveDocument.Bookmarks("Test1").End
With rTmp.Find
.Text = TextBox1.Text
If .Execute Then
rTmp.Font.Underline = wdUnderlineSingle
End If
End With
End Sub
Note, that you won't see the result,
before the userform is closed.
--
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
Vista Small Business, Office XP
Bigfoot17 - 27 May 2008 20:36 GMT
Sorry I was not clear. You previous help was great, and appreciated, I am
now able to underline bookmarked text. That triggered my second related
questions of underlining text within a string. Now I am off to learn from
your 2nd response.
> Hi Bigfoot17,
>
[quoted text clipped - 48 lines]
>
> Vista Small Business, Office XP