Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-25-2012, 09:52 AM
sinbad sinbad is offline Coding into a macro a carriage return Windows 7 32bit Coding into a macro a carriage return Office 2010 32bit
Novice
Coding into a macro a carriage return
 
Join Date: Feb 2012
Posts: 2
sinbad is on a distinguished road
Default 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:
Sub HeaderFooterObjectBest_English()
Dim MyText As String


MyHeaderText = "..........................."
MyHeaderText = "Paul | new words for the week | Best-English.org | 1 of 1"
MyFooterText = "Best-English dot org"
Selection.Font.Name = "Courier New"
Selection.Font.Size = 9
With ActiveDocument.Sections(1)
.Headers(wdHeaderFooterPrimary).Range.Text = MyHeaderText
.Footers(wdHeaderFooterPrimary).Range.Text = MyFooterText
End With
End Sub
Be very grateful for guidance.
Reply With Quote
  #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: 3,900
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
  #3  
Old 02-26-2012, 02:50 AM
sinbad sinbad is offline Coding into a macro a carriage return Windows 7 32bit Coding into a macro a carriage return Office 2010 32bit
Novice
Coding into a macro a carriage return
 
Join Date: Feb 2012
Posts: 2
sinbad is on a distinguished road
Default

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
Reply With Quote
  #4  
Old 02-26-2012, 03:35 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: 3,900
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

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
Reply With Quote
  #5  
Old 02-26-2012, 10:10 PM
macropod's Avatar
macropod macropod is offline Coding into a macro a carriage return Windows 7 64bit Coding into a macro a carriage return Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #6  
Old 02-27-2012, 02:53 AM
strongm strongm is offline Coding into a macro a carriage return Windows 7 64bit Coding into a macro a carriage return Office 2010 64bit
Novice
 
Join Date: Feb 2012
Posts: 1
strongm is on a distinguished road
Default

Quote:
Originally Posted by Stefan Blom View Post
A vertical tab is a line that "cuts" vertically through the paragraph at the specified location.
That is a bar tab, which is really just a text decoration, and nothing like a vertical tab.
Reply With Quote
  #7  
Old 02-27-2012, 03:51 AM
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: 3,900
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

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

Thread Tools
Display Modes


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 05:40 AM.


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