#1
|
|||
|
|||
Coding into a macro a carriage return
I can't find a way to put two lines into a header via a macro. I want to say, Put this text in the header .... 'header text header text'
And put these full points underneath '..................................' So it's a two-line header. My macro doesn't work this way .... Quote:
|
#2
|
||||
|
||||
You can work with the range object directly to easily add a return (paragraph mark):
Code:
Sub AddTwoLinesToHeader() Dim r As Range Set r = ActiveDocument.Sections(1).Headers _ (wdHeaderFooterPrimary) _ .Range.Duplicate r.Text = "" 'clear header content With r .InsertAfter "This is some text." .InsertParagraphAfter .InsertAfter "This is a new para." End With End Sub
__________________
Stefan Blom Microsoft Word MVP Microsoft 365 apps for business Windows 11 Professional |
#3
|
|||
|
|||
Thanks very much, Stefan. Interesting to see it done that way. I think the term I looked for was a 'vertical tab' which I think is coded as vbVerticalTab. Glad to see this other way. Very grateful. Cheers paul
|
#4
|
||||
|
||||
A vertical tab is a line that "cuts" vertically through the paragraph at the specified location. In the user interface, you can add it by clicking on the horizontal ruler (if you first click to display the | symbol on the tab/indent selector). You can add it by working with the appropriate range object.
__________________
Stefan Blom Microsoft Word MVP Microsoft 365 apps for business Windows 11 Professional |
#5
|
||||
|
||||
Cross-posted at: http://www.tek-tips.com/viewthread.cfm?qid=1676130
For cross-posting etiquette, please read: http://www.excelguru.ca/content.php?184
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#6
|
|||
|
|||
That is a bar tab, which is really just a text decoration, and nothing like a vertical tab.
|
#7
|
||||
|
||||
OK, then we have established that I am not 100% sure what you are trying to accomplish. :-)
__________________
Stefan Blom Microsoft Word MVP Microsoft 365 apps for business Windows 11 Professional |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Paragraph (carriage) return font size | revrossreddick | Word | 2 | 12-28-2011 01:33 PM |
Converting data-table into coding text | niuri_cigarete | Excel | 2 | 12-10-2011 02:57 AM |
Extreme Color Coding Outlook | boodmatt | Outlook | 0 | 06-27-2011 02:13 AM |
Return to in box | cjwilson2740 | Outlook | 0 | 04-05-2010 02:27 PM |
Carriage Return Help | UCHelp | Word | 1 | 04-04-2010 10:11 PM |