hi,
I'm creating a word document programatically using VBA.
1) I have a a string with value - "Strategy". I want to make it bold and to be displayed in the word document.
I have tried this below, but the text is never changed:
Dim wrdApp As Word.Application
Dim wrdDoc As Word.Document
Set wrdApp = CreateObject("Word.Application")
Dim strategy As String
strategy = "STRATEGY"
Dim objWdRange As Word.Range
wrdApp.Visible = True
Set wrdDoc = wrdApp.Documents.Open("C:\Program Files\DailyStrategy.doc")
With wrdDoc
If wrdDoc.Bookmarks.Exists("MarketCommentry") Then
wrdDoc.Bookmarks("MarketCommentry").Range.Text = strategy
Set objWdRange = wrdDoc.Content
With objWdRange.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "STRATEGY"
'Make found bold and italic
With .Replacement.Font
.Bold = True
.Italic = True
End With
.Execute Replace:=wdReplaceAll
End With
End With
End If
regards
Kojo