Hi Folks,
Another trip to the well for a Word VBA Newb...
I have VBA code which opens a Word instance and programmatically populates the document with tables. However, each table must have a title, so my code is:
Code:
Selection.Text = " Product Specifications"
Selection.Font.Name = "calibri"
Selection.Font.Size = 16
Selection.Font.Bold = True
Selection.EndKey Unit:=wdStory
'Now add table...
.Tables.Add Range:=Selection.Range, NumRows:=3, NumColumns:=4, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:=wdAutoFitFixed
Now, if I want the title underlined, the code becomes:
Code:
Selection.Text = " Product Specifications"
Selection.Font.Name = "calibri"
Selection.Font.Size = 16
Selection.Font.Bold = True
Selection.Font.Underline = wdUnderlineSingle
Selection.EndKey Unit:=wdStory
'Now add table...
.Tables.Add Range:=Selection.Range, NumRows:=3, NumColumns:=4, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:=wdAutoFitFixed
.
Of course, when I do, everything in the document after that line is underlined.
I only want the titles underlined. What am I doing wrong, please?
Thanks,
-John