Hi =?Utf-8?B?U3RldmUgQy4=?=,
I just read your posting of 3/21 on same subject and wonder if it is
difficult to change the footer texts to adding built-in Auto Text functions
like '-PAGE' - or 'Created On'.
It is much appreciated if you are kind enough to show the VB codes for
achieving the task as you did on 3/21.
These are actually FIELDS; the PAGE and CREATEDATE fields, respectively. So
what you need to do are insert the field codes in the appropriate position.
Unfortunately, you haven't told me WHERE in the header/footer they should be.
For my example, I'm going to make the following assumptions:
1. Your footer has three "regions" for text: left aligned, centered,
right-aligned
2. These "regions" are defined with tab stops: a center-align tab stop in the
middle of the page; a right-align tab stop at the right margin. (This is how
Word sets up headers/footers by installation default.)
3. The page number will be centered, surrounded by dashes
4. The "Created on" will be right-aligned, with the text (as the AutoText entry
appears)
Sub CreateFooter()
Dim doc As Word.Document
Dim rngFooter As Word.Range
Dim rngTabContent As Word.Range
Dim fld As Word.Field
Set doc = ActiveDocument
Set rngFooter = _
doc.Sections(1).Footers(wdHeaderFooterPrimary).Range
Set rngTabContent = rngFooter.Duplicate
rngTabContent.Text = "left margin text" & vbTab & "- "
rngTabContent.Collapse wdCollapseEnd
Set fld = doc.Fields.Add(Range:=rngTabContent, Text:="PAGE",
PreserveFormatting:=False)
Set rngTabContent = rngFooter.Duplicate
rngTabContent.Collapse wdCollapseEnd
rngTabContent.Text = " -" & vbTab & "Created on: "
rngTabContent.Collapse wdCollapseEnd
Set fld = doc.Fields.Add(Range:=rngTabContent, Text:="CreateDate \@ " &
Chr$(34) & "MMMM d yyyy" & Chr$(34), PreserveFormatting:=False)
End Sub
Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org
This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail