Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-20-2019, 11:14 PM
Ludo_Soete Ludo_Soete is offline Underline word(s) over the whole page width using VBA Windows 7 64bit Underline word(s) over the whole page width using VBA Office 2010
Novice
Underline word(s) over the whole page width using VBA
 
Join Date: Oct 2019
Posts: 2
Ludo_Soete is on a distinguished road
Angry Underline word(s) over the whole page width using VBA

Hi,



If i type a word, or words, followed by a CR LF, followed by 3 consecutive underline characters, then is the result a full line under the typed word(s) stretching from the left side of the page to the right side of the page - see picture on the bottom of the message.
This is not the same as underlining the word(s), the line spacing is also different as you can see in the picture.

I would like to obtain this using VBA, but I'm not lucky at all.
I record a macro, see code below, but this is only placing the 3 underline characters on a new line, not what I expected.

How can this be done?
I'm new with Word & VBA for Word, no experience at all.

Ludo

Code:
Sub Macro8()
'
' Macro8 Macro
'
'
    Selection.TypeText Text:="titel"
    Selection.TypeParagraph
    Selection.TypeText Text:="___"
    Selection.TypeParagraph
End Sub
Attached Images
File Type: png Word Title Underline.png (3.5 KB, 15 views)
Reply With Quote
  #2  
Old 10-21-2019, 12:14 AM
gmayor's Avatar
gmayor gmayor is offline Underline word(s) over the whole page width using VBA Windows 10 Underline word(s) over the whole page width using VBA Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Use a paragraph border e.g.

Code:
Sub Macro1()
    Selection.TypeText Text:="titel"
    With Selection.ParagraphFormat.Borders(wdBorderBottom)
        .LineStyle = wdLineStyleSingle
        .LineWidth = wdLineWidth150pt
        .Color = wdColorAutomatic
    End With
End Sub
You may also find Lined Headings useful
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 10-21-2019, 04:59 AM
Ludo_Soete Ludo_Soete is offline Underline word(s) over the whole page width using VBA Windows 7 64bit Underline word(s) over the whole page width using VBA Office 2010
Novice
Underline word(s) over the whole page width using VBA
 
Join Date: Oct 2019
Posts: 2
Ludo_Soete is on a distinguished road
Default

Quote:
Originally Posted by gmayor View Post
Use a paragraph border e.g.

Code:
Sub Macro1()
    Selection.TypeText Text:="titel"
    With Selection.ParagraphFormat.Borders(wdBorderBottom)
        .LineStyle = wdLineStyleSingle
        .LineWidth = wdLineWidth150pt
        .Color = wdColorAutomatic
    End With
End Sub
You may also find Lined Headings useful
Thanks for this fast reply.
Works great.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to adapt a text pasted from PDF to the full width of a microsoft word page Alessio Word 2 01-13-2018 03:35 PM
Underline word(s) over the whole page width using VBA Underline at bottom of page won't go away yachts66 Word 3 08-13-2014 07:28 AM
Underline word(s) over the whole page width using VBA How do you delete the UNDERLINE from a Title that remains on The previous page. Dane_s_13 Word 4 02-20-2013 04:55 PM
Underline word(s) over the whole page width using VBA Word 2012: Change column width changes table width OpfinnarJocke Word Tables 1 09-22-2012 04:03 AM
Underline word(s) over the whole page width using VBA Word is inserting bold page-width lines without permission! kozureokami Word 6 05-22-2011 02:59 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:35 PM.


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