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

I am looking at the main document *before* beginning the merge:

Dim docSource As Word.DocumentClass = GetObject(SourceFile)

''' Do the mail merge
merge = docSource.MailMerge
With merge
For Each field As Word.MailMergeField In .Fields
Dim txt As String = field.Code.Text.Trim()
If txt.StartsWith("MERGEFIELD") Then
''' Process the field
End If
Next
end with

I set a breakpoint on the "erge=..." line, then use watches to explore the
document tree. In particular, docSource.merge.fields.count == 0 (which
proves true when I step through the code, it skips over the "for each...")

Thank you for the code snippett - I'll be exploring it today.

EB