View Single Post
  #5   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson
 
Posts: n/a
Default Please help - Missing headers in mail merge

Good.

You may be able to find more fields by looking in the shapes in the
headers/footers and Text Frames, using e.g.

Dim iStories As Integer
Dim objSection As Section
Dim objHeaderFooter As HeaderFooter
Dim r As Range
Dim s As Shape
For Each objSection in ActiveDocument.Sections
For Each objHeaderFooter in objSection. Headers
For Each s in objHeaderFooter.Shapes
If s.TextFrame.HasText Then
' use s.TextFrame.TextRange to find the fields
End If
Next s
Next objHeaderFooter
For Each objHeaderFooter in objSection.Footers
For Each s in objHeaderFooter.Shapes
If s.TextFrame.HasText Then
' use s.TextFrame.TextRange to find the fields
End If
Next s
Next objHeaderFooter
Next objSection
End Sub
For Each r in ActiveDocument.StoryRanges
If r.StoryType = wdTextFrameStory Then
While Not (r.NextStoryRange Is Nothing)
Set r = r.NextStoryRange
Wend
End If
Next r

Fields in text boxes can be a bit dodgy enyway, although sometimes they may
be the only way to do certain things. Fields in old-style Word frames are
generally a better idea if the user has to use out-of line texts.

Peter Jamieson

"Earl B" wrote in message
. ..
That CERTAINLY helped! I still have some content that is in TextFrame
objects (I ~think~ it's in textframe objects), but I can mandate "don't
use
those" easily enough.

Thanks!