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 / November 2007

Tip: Looking for answers? Try searching our database.

Adding AutoText to all headers and footers

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
LunaSlashSea@gmail.com - 31 Aug 2006 19:20 GMT
Is there a way to add an autotext entry to ALL headers and footers in a
document no matter if there is a different first page or not, or if
there are multiple sections or not?
Greg Maxey - 31 Aug 2006 19:41 GMT
Perhaps something like:

Sub ScratchMacro()
Dim oDoc As Document
Dim oRng As Word.Range
Dim oSec As Long
Dim i As Long
Set oDoc = ActiveDocument
For oSec = 1 To oDoc.Sections.Count
 With oDoc.Sections(oSec)
   For i = 1 To 3
     With .Headers(i)
       .LinkToPrevious = False
       .Range.InsertAfter
oDoc.AttachedTemplate.AutoTextEntries("ATTN:")
     End With
     With .Footers(i)
       .LinkToPrevious = False
       .Range.InsertAfter
oDoc.AttachedTemplate.AutoTextEntries("ATTN:")
     End With
   Next i
 End With
Next oSec
End Sub

> Is there a way to add an autotext entry to ALL headers and footers in a
> document no matter if there is a different first page or not, or if
> there are multiple sections or not?
fumei - 29 Nov 2007 21:49 GMT
Or...

Sub AllHeaders()
Dim oHF As HeaderFooter
Dim oSection As Section
For Each oSection In ActiveDocument.Sections
  For Each oHF in oSection.Headers
        NormalTemplate.AutoTextEntries("Attn:").Insert _
          Where:=oHF.Range, RichText:=True
  Next
  For Each oHF in oSection.Footers
        NormalTemplate.AutoTextEntries("Attn:").Insert _
          Where:=oHF.Range, RichText:=True
  Next
Next
End Sub

No loops, or counters.  Adjusted for NormalTemplate vs. AttachedTemplate as
required of course.

 

>Perhaps something like:
>
[quoted text clipped - 25 lines]
>> document no matter if there is a different first page or not, or if
>> there are multiple sections or not?
 
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



©2010 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.