Need to bold a line in Word document
Posted on 2008-10-21
Using vb.net, Word 2003, not quite sure why the following function isn't working. The do while evaluates to true, but it passes right over the with clause. I use something almost identical to find and delete an entire line, so I'm not quite sure what's going on. BTW, I want to find the text "Your Ref:", and then bold the entire line where this string resides; also, it always resides at the beginning of the line.
Sub BoldYourRef(ByVal doc As Object)
Dim wdApp As Object 'Word.Application
Dim Unit1 As Microsoft.Office.Interop.Word.WdUnits = Microsoft.Office.Interop.Word.WdUnits.wdLine
wdApp = doc.Application
wdApp.Selection.Find.Text = "Your Ref:"
Do While wdApp.Selection.Find.Execute(FindText:="Your Ref:", Forward:=True, _
Format:=True) = True
wdApp.selection.Font.Bold = True