Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 01-11-2017, 10:55 AM
jmltinc jmltinc is offline Underline Inserted Text Windows 7 64bit Underline Inserted Text Office 2016
Novice
Underline Inserted Text
 
Join Date: Jan 2017
Posts: 9
jmltinc is on a distinguished road
Default Underline Inserted Text

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
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Replacing a comment with underline or other formatting (or adding that formatting to commented text) paulkaye Word 4 05-16-2016 05:38 AM
Underline Inserted Text Is there a way of having text automatically inserted based on the selection of other text? MiniMum97 Word 2 04-12-2016 06:09 AM
Copy Underline text from Word and Paste into excel rfaris Excel Programming 7 10-05-2015 05:56 AM
Underline Inserted Text Select text to be underline and bold ksigcajun Word VBA 1 03-16-2015 07:51 PM
How to remove the UNDERLINE from a hyperlink text? Learner7 PowerPoint 3 05-17-2010 09:35 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:59 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft