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

1. Can you spell out what you mean by

"When I debug the merge process, there
are *no* merge fields listed in the document, but the finished document has
the fields listed."

There's a starting document called the Mail Merge Main Document, and a
result document (when you merge to a new document, that is). Which contains
what, and how are you finding out?

2. The chances are the the .NET tool is not looking for fields in all the
StoryRanges in the document. Detecting /all/ fields in a document is
non-trivial (in fact, evidence suggests that it may not be possible) but the
following code should catch most of them:

Dim objStory As Range
Dim objField As Field

For Each objStory In ActiveDocument.StoryRanges
For Each objField In objStory.Fields
' do what you want to the field here
Next
' The header/footer ranges can be linked in a way
' that is not revealed by the outer For Each
' so we have to do the following
While Not (objStory.NextStoryRange Is Nothing)
Set objStory = objStory.NextStoryRange
For Each objField In objStory.Fields
' do what you want to the field here
Next
Wend
Next objStory

Set objStory = Nothing
Set objField = Nothing

2. What kind of merge is the user performing? Fields in the header/footer
are likely to behave differently in Catalog/Directory merges than they do in
Letter merges.

Peter Jameieson

"Earl B" wrote in message
. ..
I have a VB.Net tool that is performing a programmatic mail-merge, and one
of my users is putting the merge fields in the header for the document.

For some reason, this isn't working. When I debug the merge process,
there
are *no* merge fields listed in the document, but the finished document
has
the fields listed.

Does this sound familiar to anybody? Can someone give me a link to an
answer? I'm under the gun on this one, and your help is GREATLY
appreciated!


EB