csharp_learner
asked on
vba write to word document underlined and bold
Hi,
I am trying to write a vba script in Excel 2007 and the objective is to open an existing word 2007 document and write a date into the Bookmark with the font bold and underlined.
I have managed to open the word document and write the date value into the Bookmark, but i can't seem to make the font bold or underlined.
The following is my code:
Set wordapp = New Word.Application
Set myDoc = wordapp.Documents.Open("C: \Template. doc")
' Write into word Bookmark
If myDoc.Bookmarks.Exists("Cu rrentMonth ") Then
'how to make font Bold and underlined???
myDoc.Bookmarks("CurrentMo nth").Rang e.Text = Format(dEndMth, "d MMMM yyyy")
End If
I am trying to write a vba script in Excel 2007 and the objective is to open an existing word 2007 document and write a date into the Bookmark with the font bold and underlined.
I have managed to open the word document and write the date value into the Bookmark, but i can't seem to make the font bold or underlined.
The following is my code:
Set wordapp = New Word.Application
Set myDoc = wordapp.Documents.Open("C:
' Write into word Bookmark
If myDoc.Bookmarks.Exists("Cu
'how to make font Bold and underlined???
myDoc.Bookmarks("CurrentMo
End If
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Replace the code with my if statement and it worked.
Thanks for the prompt solution.
Thanks for the prompt solution.
ASKER
This code is before, after or to replace the If statement?