Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / August 2006

Tip: Looking for answers? Try searching our database.

Creating a format for headers

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Stork - 31 Aug 2006 17:28 GMT
I would like to create a format in word that makes it possible to transfer a
word from the text to a header. For example, if I write:

"This is my header"

in the text, I would like to be able to mark that text and chose a format
which automatically converts that text into a header.

Does anyone understand what I mean? And if so, is it possible?
Greg Maxey - 31 Aug 2006 18:08 GMT
I am not sure that I understand what you mean.  The following will take
selected text in the document and put it in the headers as centered red
text.  Perhaps you can adapt to your needs.

Sub ScratchMacro()
Dim oDoc As Document
Dim oRng As Word.Range
Dim myHdrText As String
Dim i As Long
Set oDoc = ActiveDocument
myHdrText = Selection.Text
With oDoc.Sections(1)
 For i = 1 To 3
 With .Headers(i)
   Set oRng = .Range
   With oRng
     .Delete
     .ParagraphFormat.Alignment = wdAlignParagraphCenter
     .Text = myHdrText
     .Font.Color = wdColorRed
   End With
 End With
 Next i
End With
End Sub

> I would like to create a format in word that makes it possible to transfer a
> word from the text to a header. For example, if I write:
[quoted text clipped - 5 lines]
>
> Does anyone understand what I mean? And if so, is it possible?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.