Link to home
Start Free TrialLog in
Avatar of csharp_learner
csharp_learnerFlag for Singapore

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("CurrentMonth") Then
        'how to make font Bold and underlined???
        myDoc.Bookmarks("CurrentMonth").Range.Text = Format(dEndMth, "d MMMM yyyy")

    End If
ASKER CERTIFIED SOLUTION
Avatar of Rgonzo1971
Rgonzo1971

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of csharp_learner

ASKER

Thanks for the prompt reply.

This code is before, after or to replace the If statement?
Replace the code with my if statement and it worked.

Thanks for the prompt solution.