Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 02-25-2012, 06:11 PM
Stefan Blom's Avatar
Stefan Blom Stefan Blom is offline Coding into a macro a carriage return Windows 7 64bit Coding into a macro a carriage return Office 2010 32bit
Moderator
 
Join Date: Aug 2011
Posts: 4,036
Stefan Blom is a name known to allStefan Blom is a name known to allStefan Blom is a name known to allStefan Blom is a name known to allStefan Blom is a name known to allStefan Blom is a name known to all
Default

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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Coding into a macro a carriage return Paragraph (carriage) return font size revrossreddick Word 2 12-28-2011 01:33 PM
Coding into a macro a carriage return 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

Other Forums: Access Forums

All times are GMT -7. The time now is 08:45 AM.


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