Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Ed Ed is offline
external usenet poster
 
Posts: 217
Default Automated mail merge problem

Hello All,

One of our clients has reported a problem with mail merge when the merge is
run programmatically. It looks like a Word bug but I wonder if anyone can
advise.

To test, I'm using a document which has a couple of merge fields (Field1,
Field2) and a date field in a header. I'm using Word 2003 but I don't think
the issue is limited to that.

I automate the merge and after the merge, if I move the insertion point past
the section break that the mail merge inserted, and then arrange for the
document to have an extra page (e.g. by Ctrl+Enter), the merge fields in the
second (and subsequent) section's header are "Field1" and "Field2"
rather than the proper values. The date field is OK. If I perform the merge
manually (not using code) I don't get the problem.

I'm using the following VBA code in Word for the test:

----------------------------------------------------------------------------------------------
Sub MergeTest()
Const MMMDoc = "C:\temp\TestDoc.doc"
Const DataFile = "C:\temp\TestData.edc"
Dim MergeDoc As Document

Set MergeDoc = Documents.Open(MMMDoc)

With ActiveDocument.MailMerge
.MainDocumentType = wdFormLetters
.SuppressBlankLines = True
.OpenDataSource Name:=DataFile, _
Format:=wdOpenFormatText, _
ConfirmConversions:=False, _
ReadOnly:=True, _
LinkToSource:=False
.Execute
End With
End Sub
----------------------------------------------------------------------------------------------

The data file is a tilde-delimited text file.

Thanks.

Ed
  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Automated mail merge problem

Hi Ed,

I tried this here (Word 2003, Win XP SP2) and I /always/ see the field1
and field2 in the new header whether I use automation to merge the
document or do it manually.

If I use the following code to display what headers/footers Word sees in the
merged document, I see the text for each section (letter) /and/ the
field1 text at the very end, even before you insert the new page break,
though the header is not visible in the document.

I think this has to do with the fact that Word actually appends a
"continuous" section break at the end of the document - possibly because it
doesn't know whether or not it is going to append another letter in the
output - and messes around with the header/footer as it does so. Precisely
what it does, I do not know, but one or two KB articles provide some hints,
e.g.

http://support.microsoft.com/kb/109684/en-us

Nor do I know why /yours/ works OK when you merge manually, sorry!

Peter Jamieson

"Ed" wrote in message
...
Hello All,

One of our clients has reported a problem with mail merge when the merge
is
run programmatically. It looks like a Word bug but I wonder if anyone can
advise.

To test, I'm using a document which has a couple of merge fields (Field1,
Field2) and a date field in a header. I'm using Word 2003 but I don't
think
the issue is limited to that.

I automate the merge and after the merge, if I move the insertion point
past
the section break that the mail merge inserted, and then arrange for the
document to have an extra page (e.g. by Ctrl+Enter), the merge fields in
the
second (and subsequent) section's header are "Field1" and "Field2"
rather than the proper values. The date field is OK. If I perform the
merge
manually (not using code) I don't get the problem.

I'm using the following VBA code in Word for the test:

----------------------------------------------------------------------------------------------
Sub MergeTest()
Const MMMDoc = "C:\temp\TestDoc.doc"
Const DataFile = "C:\temp\TestData.edc"
Dim MergeDoc As Document

Set MergeDoc = Documents.Open(MMMDoc)

With ActiveDocument.MailMerge
.MainDocumentType = wdFormLetters
.SuppressBlankLines = True
.OpenDataSource Name:=DataFile, _
Format:=wdOpenFormatText, _
ConfirmConversions:=False, _
ReadOnly:=True, _
LinkToSource:=False
.Execute
End With
End Sub
----------------------------------------------------------------------------------------------

The data file is a tilde-delimited text file.

Thanks.

Ed



  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Ed Ed is offline
external usenet poster
 
Posts: 217
Default Automated mail merge problem

Hi Peter,

Thanks for the reply.

I've re-checked whether I get the problem when I merge manually and I still
don't. I'm using Win XP Pro SP2.

I forgot to mention in the original post that most of the merges our clients
do are single-letter merges. That's what I was testing with. I've tried
automating a muli-letter merge and that does not seem to get the problem (for
me).

One thing that's looking like a possible workaround is to insert a
continuous section break at the end of the MMMD.

I imagine that the form letters mail merge was designed mainly for mailshots
and the combination of merge fields in a header in a single-letter merge is
relatively uncommon.

Thanks for the confirmation that you get the problem too.

Regards.

Ed

"Peter Jamieson" wrote:

Hi Ed,

I tried this here (Word 2003, Win XP SP2) and I /always/ see the field1
and field2 in the new header whether I use automation to merge the
document or do it manually.

If I use the following code to display what headers/footers Word sees in the
merged document, I see the text for each section (letter) /and/ the
field1 text at the very end, even before you insert the new page break,
though the header is not visible in the document.

I think this has to do with the fact that Word actually appends a
"continuous" section break at the end of the document - possibly because it
doesn't know whether or not it is going to append another letter in the
output - and messes around with the header/footer as it does so. Precisely
what it does, I do not know, but one or two KB articles provide some hints,
e.g.

http://support.microsoft.com/kb/109684/en-us

Nor do I know why /yours/ works OK when you merge manually, sorry!

Peter Jamieson

"Ed" wrote in message
...
Hello All,

One of our clients has reported a problem with mail merge when the merge
is
run programmatically. It looks like a Word bug but I wonder if anyone can
advise.

To test, I'm using a document which has a couple of merge fields (Field1,
Field2) and a date field in a header. I'm using Word 2003 but I don't
think
the issue is limited to that.

I automate the merge and after the merge, if I move the insertion point
past
the section break that the mail merge inserted, and then arrange for the
document to have an extra page (e.g. by Ctrl+Enter), the merge fields in
the
second (and subsequent) section's header are "Field1" and "Field2"
rather than the proper values. The date field is OK. If I perform the
merge
manually (not using code) I don't get the problem.

I'm using the following VBA code in Word for the test:

----------------------------------------------------------------------------------------------
Sub MergeTest()
Const MMMDoc = "C:\temp\TestDoc.doc"
Const DataFile = "C:\temp\TestData.edc"
Dim MergeDoc As Document

Set MergeDoc = Documents.Open(MMMDoc)

With ActiveDocument.MailMerge
.MainDocumentType = wdFormLetters
.SuppressBlankLines = True
.OpenDataSource Name:=DataFile, _
Format:=wdOpenFormatText, _
ConfirmConversions:=False, _
ReadOnly:=True, _
LinkToSource:=False
.Execute
End With
End Sub
----------------------------------------------------------------------------------------------

The data file is a tilde-delimited text file.

Thanks.

Ed




  #4   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Ed Ed is offline
external usenet poster
 
Posts: 217
Default Automated mail merge problem

Hi again,

From my other reply ...
I've tried automating a muli-letter merge and that does not seem to get the problem (for me).


I've just being trying again and I do get the problem when automating this
type of merge. Think I was just mistaken the first time.

Regards.

Ed
"Peter Jamieson" wrote:

Hi Ed,

I tried this here (Word 2003, Win XP SP2) and I /always/ see the field1
and field2 in the new header whether I use automation to merge the
document or do it manually.

If I use the following code to display what headers/footers Word sees in the
merged document, I see the text for each section (letter) /and/ the
field1 text at the very end, even before you insert the new page break,
though the header is not visible in the document.

I think this has to do with the fact that Word actually appends a
"continuous" section break at the end of the document - possibly because it
doesn't know whether or not it is going to append another letter in the
output - and messes around with the header/footer as it does so. Precisely
what it does, I do not know, but one or two KB articles provide some hints,
e.g.

http://support.microsoft.com/kb/109684/en-us

Nor do I know why /yours/ works OK when you merge manually, sorry!

Peter Jamieson

"Ed" wrote in message
...
Hello All,

One of our clients has reported a problem with mail merge when the merge
is
run programmatically. It looks like a Word bug but I wonder if anyone can
advise.

To test, I'm using a document which has a couple of merge fields (Field1,
Field2) and a date field in a header. I'm using Word 2003 but I don't
think
the issue is limited to that.

I automate the merge and after the merge, if I move the insertion point
past
the section break that the mail merge inserted, and then arrange for the
document to have an extra page (e.g. by Ctrl+Enter), the merge fields in
the
second (and subsequent) section's header are "Field1" and "Field2"
rather than the proper values. The date field is OK. If I perform the
merge
manually (not using code) I don't get the problem.

I'm using the following VBA code in Word for the test:

----------------------------------------------------------------------------------------------
Sub MergeTest()
Const MMMDoc = "C:\temp\TestDoc.doc"
Const DataFile = "C:\temp\TestData.edc"
Dim MergeDoc As Document

Set MergeDoc = Documents.Open(MMMDoc)

With ActiveDocument.MailMerge
.MainDocumentType = wdFormLetters
.SuppressBlankLines = True
.OpenDataSource Name:=DataFile, _
Format:=wdOpenFormatText, _
ConfirmConversions:=False, _
ReadOnly:=True, _
LinkToSource:=False
.Execute
End With
End Sub
----------------------------------------------------------------------------------------------

The data file is a tilde-delimited text file.

Thanks.

Ed




  #5   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Automated mail merge problem

HI Ed,

Not much more to offer...

I tried the "one record only" scenario thinking perhaps we might end up
doing a tit-for-tat :-), but at the moment I still /always/ get the
field1 stuff no matter ho I actually initiate the merge. It's always
possible that another factor/setting is involved. The most obvious to me was
showing/hiding using the pilcrow button and the possibility that the precise
location of the insertion point might make a difference, but apparently not.


I imagine that the form letters mail merge was designed mainly for mailshots


I don't know, but my guess is that it's more likely that someone said "we
need some sort of mail merge facility" and somone else trying to design a
different bunch of stuff said "let's associate the properties of a Word
section in the section mark, or in the final paragraph mark of a Word
document if there is only one section", no-one spent much time thinking
about "but what if you need to transform a single-section document into a
multi-section document?" and here we are...


and the combination of merge fields in a header in a single-letter merge is
relatively uncommon.


....I'd say "adding new pages to the output of a 'Letter' merge" is probably
not that common, although "inserting stuff at the beginning and end of a
Catalog/Directory merge seems to me to be something that anyone producing a
Catalog might want to do, and perhaps doing the same for a letter is not
that large a reach of the imagination. It would be nice if all this stuff
did work in a slightly more obvious way that was less determined by a model
of a Word document conceived for non-mailmerge applications, but here we
are...

Peter Jamieson


"Ed" wrote in message
...
Hi again,

From my other reply ...
I've tried automating a muli-letter merge and that does not seem to get
the problem (for me).


I've just being trying again and I do get the problem when automating this
type of merge. Think I was just mistaken the first time.

Regards.

Ed
"Peter Jamieson" wrote:

Hi Ed,

I tried this here (Word 2003, Win XP SP2) and I /always/ see the
field1
and field2 in the new header whether I use automation to merge the
document or do it manually.

If I use the following code to display what headers/footers Word sees in
the
merged document, I see the text for each section (letter) /and/ the
field1 text at the very end, even before you insert the new page
break,
though the header is not visible in the document.

I think this has to do with the fact that Word actually appends a
"continuous" section break at the end of the document - possibly because
it
doesn't know whether or not it is going to append another letter in the
output - and messes around with the header/footer as it does so.
Precisely
what it does, I do not know, but one or two KB articles provide some
hints,
e.g.

http://support.microsoft.com/kb/109684/en-us

Nor do I know why /yours/ works OK when you merge manually, sorry!

Peter Jamieson

"Ed" wrote in message
...
Hello All,

One of our clients has reported a problem with mail merge when the
merge
is
run programmatically. It looks like a Word bug but I wonder if anyone
can
advise.

To test, I'm using a document which has a couple of merge fields
(Field1,
Field2) and a date field in a header. I'm using Word 2003 but I don't
think
the issue is limited to that.

I automate the merge and after the merge, if I move the insertion point
past
the section break that the mail merge inserted, and then arrange for
the
document to have an extra page (e.g. by Ctrl+Enter), the merge fields
in
the
second (and subsequent) section's header are "Field1" and
"Field2"
rather than the proper values. The date field is OK. If I perform the
merge
manually (not using code) I don't get the problem.

I'm using the following VBA code in Word for the test:

----------------------------------------------------------------------------------------------
Sub MergeTest()
Const MMMDoc = "C:\temp\TestDoc.doc"
Const DataFile = "C:\temp\TestData.edc"
Dim MergeDoc As Document

Set MergeDoc = Documents.Open(MMMDoc)

With ActiveDocument.MailMerge
.MainDocumentType = wdFormLetters
.SuppressBlankLines = True
.OpenDataSource Name:=DataFile, _
Format:=wdOpenFormatText, _
ConfirmConversions:=False, _
ReadOnly:=True, _
LinkToSource:=False
.Execute
End With
End Sub
----------------------------------------------------------------------------------------------

The data file is a tilde-delimited text file.

Thanks.

Ed







  #6   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Ed Ed is offline
external usenet poster
 
Posts: 217
Default Automated mail merge problem

Hi Peter,

no-one spent much time thinking about "but what if you need to transform a single-section document into a multi-section document?" and here we are...


Yes. At the moment (and my view changes from minute to minute) it kind of
looks like in a "Letter" merge Word "knows" that each section but the last is
a "Letter" and so it handle these properly, but it misses out a step or two
in the last section.

I've got to do a bit more testing of the "insert a continuous section break
at the end of the MMMD" approach - in part because it doesn't make much sense
to me as to why that seems to work. But if it does, good enough in the
circumstances.

Cheers.

Ed

"Peter Jamieson" wrote:

HI Ed,

Not much more to offer...

I tried the "one record only" scenario thinking perhaps we might end up
doing a tit-for-tat :-), but at the moment I still /always/ get the
field1 stuff no matter ho I actually initiate the merge. It's always
possible that another factor/setting is involved. The most obvious to me was
showing/hiding using the pilcrow button and the possibility that the precise
location of the insertion point might make a difference, but apparently not.


I imagine that the form letters mail merge was designed mainly for mailshots


I don't know, but my guess is that it's more likely that someone said "we
need some sort of mail merge facility" and somone else trying to design a
different bunch of stuff said "let's associate the properties of a Word
section in the section mark, or in the final paragraph mark of a Word
document if there is only one section", no-one spent much time thinking
about "but what if you need to transform a single-section document into a
multi-section document?" and here we are...


and the combination of merge fields in a header in a single-letter merge is
relatively uncommon.


....I'd say "adding new pages to the output of a 'Letter' merge" is probably
not that common, although "inserting stuff at the beginning and end of a
Catalog/Directory merge seems to me to be something that anyone producing a
Catalog might want to do, and perhaps doing the same for a letter is not
that large a reach of the imagination. It would be nice if all this stuff
did work in a slightly more obvious way that was less determined by a model
of a Word document conceived for non-mailmerge applications, but here we
are...

Peter Jamieson


"Ed" wrote in message
...
Hi again,

From my other reply ...
I've tried automating a muli-letter merge and that does not seem to get
the problem (for me).


I've just being trying again and I do get the problem when automating this
type of merge. Think I was just mistaken the first time.

Regards.

Ed
"Peter Jamieson" wrote:

Hi Ed,

I tried this here (Word 2003, Win XP SP2) and I /always/ see the
field1
and field2 in the new header whether I use automation to merge the
document or do it manually.

If I use the following code to display what headers/footers Word sees in
the
merged document, I see the text for each section (letter) /and/ the
field1 text at the very end, even before you insert the new page
break,
though the header is not visible in the document.

I think this has to do with the fact that Word actually appends a
"continuous" section break at the end of the document - possibly because
it
doesn't know whether or not it is going to append another letter in the
output - and messes around with the header/footer as it does so.
Precisely
what it does, I do not know, but one or two KB articles provide some
hints,
e.g.

http://support.microsoft.com/kb/109684/en-us

Nor do I know why /yours/ works OK when you merge manually, sorry!

Peter Jamieson

"Ed" wrote in message
...
Hello All,

One of our clients has reported a problem with mail merge when the
merge
is
run programmatically. It looks like a Word bug but I wonder if anyone
can
advise.

To test, I'm using a document which has a couple of merge fields
(Field1,
Field2) and a date field in a header. I'm using Word 2003 but I don't
think
the issue is limited to that.

I automate the merge and after the merge, if I move the insertion point
past
the section break that the mail merge inserted, and then arrange for
the
document to have an extra page (e.g. by Ctrl+Enter), the merge fields
in
the
second (and subsequent) section's header are "Field1" and
"Field2"
rather than the proper values. The date field is OK. If I perform the
merge
manually (not using code) I don't get the problem.

I'm using the following VBA code in Word for the test:

----------------------------------------------------------------------------------------------
Sub MergeTest()
Const MMMDoc = "C:\temp\TestDoc.doc"
Const DataFile = "C:\temp\TestData.edc"
Dim MergeDoc As Document

Set MergeDoc = Documents.Open(MMMDoc)

With ActiveDocument.MailMerge
.MainDocumentType = wdFormLetters
.SuppressBlankLines = True
.OpenDataSource Name:=DataFile, _
Format:=wdOpenFormatText, _
ConfirmConversions:=False, _
ReadOnly:=True, _
LinkToSource:=False
.Execute
End With
End Sub
----------------------------------------------------------------------------------------------

The data file is a tilde-delimited text file.

Thanks.

Ed





  #7   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Automated mail merge problem

Yes. At the moment (and my view changes from minute to minute) it kind of
looks like in a "Letter" merge Word "knows" that each section but the last
is
a "Letter" and so it handle these properly, but it misses out a step or
two
in the last section.


If that's so, it probably because the processing is identical for each new
section (or record in the data source) except perhaps the first, and that
there is no special processing at the end of the merge. But I'm just
speculating really.

I've got to do a bit more testing of the "insert a continuous section
break
at the end of the MMMD" approach - in part because it doesn't make much
sense
to me as to why that seems to work. But if it does, good enough in the
circumstances.


I suppose the other approach is to modify the header/footer in the new
page/section you are adding: if you want it to be exactly the same as the
previous page or section (except for stuff like page number and dates, which
are probably dealt with by the appropriate PAGE/DATE fields) there is
probably a way to do it. If you need the new header to work as if it had
been generated by a notional extra record in the data source, that might be
more difficullt (IYSWIM).

Peter Jamieson


"Ed" wrote in message
...
Hi Peter,

no-one spent much time thinking about "but what if you need to transform
a single-section document into a multi-section document?" and here we
are...


Yes. At the moment (and my view changes from minute to minute) it kind of
looks like in a "Letter" merge Word "knows" that each section but the last
is
a "Letter" and so it handle these properly, but it misses out a step or
two
in the last section.

I've got to do a bit more testing of the "insert a continuous section
break
at the end of the MMMD" approach - in part because it doesn't make much
sense
to me as to why that seems to work. But if it does, good enough in the
circumstances.

Cheers.

Ed

"Peter Jamieson" wrote:

HI Ed,

Not much more to offer...

I tried the "one record only" scenario thinking perhaps we might end up
doing a tit-for-tat :-), but at the moment I still /always/ get the
field1 stuff no matter ho I actually initiate the merge. It's always
possible that another factor/setting is involved. The most obvious to me
was
showing/hiding using the pilcrow button and the possibility that the
precise
location of the insertion point might make a difference, but apparently
not.


I imagine that the form letters mail merge was designed mainly for
mailshots


I don't know, but my guess is that it's more likely that someone said "we
need some sort of mail merge facility" and somone else trying to design a
different bunch of stuff said "let's associate the properties of a Word
section in the section mark, or in the final paragraph mark of a Word
document if there is only one section", no-one spent much time thinking
about "but what if you need to transform a single-section document into a
multi-section document?" and here we are...


and the combination of merge fields in a header in a single-letter merge
is
relatively uncommon.


....I'd say "adding new pages to the output of a 'Letter' merge" is
probably
not that common, although "inserting stuff at the beginning and end of a
Catalog/Directory merge seems to me to be something that anyone producing
a
Catalog might want to do, and perhaps doing the same for a letter is not
that large a reach of the imagination. It would be nice if all this stuff
did work in a slightly more obvious way that was less determined by a
model
of a Word document conceived for non-mailmerge applications, but here we
are...

Peter Jamieson


"Ed" wrote in message
...
Hi again,

From my other reply ...
I've tried automating a muli-letter merge and that does not seem to get
the problem (for me).

I've just being trying again and I do get the problem when automating
this
type of merge. Think I was just mistaken the first time.

Regards.

Ed
"Peter Jamieson" wrote:

Hi Ed,

I tried this here (Word 2003, Win XP SP2) and I /always/ see the
field1
and field2 in the new header whether I use automation to merge the
document or do it manually.

If I use the following code to display what headers/footers Word sees
in
the
merged document, I see the text for each section (letter) /and/ the
field1 text at the very end, even before you insert the new page
break,
though the header is not visible in the document.

I think this has to do with the fact that Word actually appends a
"continuous" section break at the end of the document - possibly
because
it
doesn't know whether or not it is going to append another letter in
the
output - and messes around with the header/footer as it does so.
Precisely
what it does, I do not know, but one or two KB articles provide some
hints,
e.g.

http://support.microsoft.com/kb/109684/en-us

Nor do I know why /yours/ works OK when you merge manually, sorry!

Peter Jamieson

"Ed" wrote in message
...
Hello All,

One of our clients has reported a problem with mail merge when the
merge
is
run programmatically. It looks like a Word bug but I wonder if
anyone
can
advise.

To test, I'm using a document which has a couple of merge fields
(Field1,
Field2) and a date field in a header. I'm using Word 2003 but I
don't
think
the issue is limited to that.

I automate the merge and after the merge, if I move the insertion
point
past
the section break that the mail merge inserted, and then arrange for
the
document to have an extra page (e.g. by Ctrl+Enter), the merge
fields
in
the
second (and subsequent) section's header are "Field1" and
"Field2"
rather than the proper values. The date field is OK. If I perform
the
merge
manually (not using code) I don't get the problem.

I'm using the following VBA code in Word for the test:

----------------------------------------------------------------------------------------------
Sub MergeTest()
Const MMMDoc = "C:\temp\TestDoc.doc"
Const DataFile = "C:\temp\TestData.edc"
Dim MergeDoc As Document

Set MergeDoc = Documents.Open(MMMDoc)

With ActiveDocument.MailMerge
.MainDocumentType = wdFormLetters
.SuppressBlankLines = True
.OpenDataSource Name:=DataFile, _
Format:=wdOpenFormatText, _
ConfirmConversions:=False, _
ReadOnly:=True, _
LinkToSource:=False
.Execute
End With
End Sub
----------------------------------------------------------------------------------------------

The data file is a tilde-delimited text file.

Thanks.

Ed






  #8   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Ed Ed is offline
external usenet poster
 
Posts: 217
Default Automated mail merge problem

Hi Peter,

I suppose the other approach is to modify the header/footer in the new
page/section you are adding ...


True. It's a shame that we have to though :-(

Still, Word is what it is, for better or worse.

Thanks for your help.

Regards.

Ed

"Peter Jamieson" wrote:

Yes. At the moment (and my view changes from minute to minute) it kind of
looks like in a "Letter" merge Word "knows" that each section but the last
is
a "Letter" and so it handle these properly, but it misses out a step or
two
in the last section.


If that's so, it probably because the processing is identical for each new
section (or record in the data source) except perhaps the first, and that
there is no special processing at the end of the merge. But I'm just
speculating really.

I've got to do a bit more testing of the "insert a continuous section
break
at the end of the MMMD" approach - in part because it doesn't make much
sense
to me as to why that seems to work. But if it does, good enough in the
circumstances.


I suppose the other approach is to modify the header/footer in the new
page/section you are adding: if you want it to be exactly the same as the
previous page or section (except for stuff like page number and dates, which
are probably dealt with by the appropriate PAGE/DATE fields) there is
probably a way to do it. If you need the new header to work as if it had
been generated by a notional extra record in the data source, that might be
more difficullt (IYSWIM).

Peter Jamieson


"Ed" wrote in message
...
Hi Peter,

no-one spent much time thinking about "but what if you need to transform
a single-section document into a multi-section document?" and here we
are...


Yes. At the moment (and my view changes from minute to minute) it kind of
looks like in a "Letter" merge Word "knows" that each section but the last
is
a "Letter" and so it handle these properly, but it misses out a step or
two
in the last section.

I've got to do a bit more testing of the "insert a continuous section
break
at the end of the MMMD" approach - in part because it doesn't make much
sense
to me as to why that seems to work. But if it does, good enough in the
circumstances.

Cheers.

Ed

"Peter Jamieson" wrote:

HI Ed,

Not much more to offer...

I tried the "one record only" scenario thinking perhaps we might end up
doing a tit-for-tat :-), but at the moment I still /always/ get the
field1 stuff no matter ho I actually initiate the merge. It's always
possible that another factor/setting is involved. The most obvious to me
was
showing/hiding using the pilcrow button and the possibility that the
precise
location of the insertion point might make a difference, but apparently
not.


I imagine that the form letters mail merge was designed mainly for
mailshots


I don't know, but my guess is that it's more likely that someone said "we
need some sort of mail merge facility" and somone else trying to design a
different bunch of stuff said "let's associate the properties of a Word
section in the section mark, or in the final paragraph mark of a Word
document if there is only one section", no-one spent much time thinking
about "but what if you need to transform a single-section document into a
multi-section document?" and here we are...


and the combination of merge fields in a header in a single-letter merge
is
relatively uncommon.


....I'd say "adding new pages to the output of a 'Letter' merge" is
probably
not that common, although "inserting stuff at the beginning and end of a
Catalog/Directory merge seems to me to be something that anyone producing
a
Catalog might want to do, and perhaps doing the same for a letter is not
that large a reach of the imagination. It would be nice if all this stuff
did work in a slightly more obvious way that was less determined by a
model
of a Word document conceived for non-mailmerge applications, but here we
are...

Peter Jamieson


"Ed" wrote in message
...
Hi again,

From my other reply ...
I've tried automating a muli-letter merge and that does not seem to get
the problem (for me).

I've just being trying again and I do get the problem when automating
this
type of merge. Think I was just mistaken the first time.

Regards.

Ed
"Peter Jamieson" wrote:

Hi Ed,

I tried this here (Word 2003, Win XP SP2) and I /always/ see the
field1
and field2 in the new header whether I use automation to merge the
document or do it manually.

If I use the following code to display what headers/footers Word sees
in
the
merged document, I see the text for each section (letter) /and/ the
field1 text at the very end, even before you insert the new page
break,
though the header is not visible in the document.

I think this has to do with the fact that Word actually appends a
"continuous" section break at the end of the document - possibly
because
it
doesn't know whether or not it is going to append another letter in
the
output - and messes around with the header/footer as it does so.
Precisely
what it does, I do not know, but one or two KB articles provide some
hints,
e.g.

http://support.microsoft.com/kb/109684/en-us

Nor do I know why /yours/ works OK when you merge manually, sorry!

Peter Jamieson

"Ed" wrote in message
...
Hello All,

One of our clients has reported a problem with mail merge when the
merge
is
run programmatically. It looks like a Word bug but I wonder if
anyone
can
advise.

To test, I'm using a document which has a couple of merge fields
(Field1,
Field2) and a date field in a header. I'm using Word 2003 but I
don't
think
the issue is limited to that.

I automate the merge and after the merge, if I move the insertion
point
past
the section break that the mail merge inserted, and then arrange for
the
document to have an extra page (e.g. by Ctrl+Enter), the merge
fields
in
the
second (and subsequent) section's header are "Field1" and
"Field2"
rather than the proper values. The date field is OK. If I perform
the
merge
manually (not using code) I don't get the problem.

I'm using the following VBA code in Word for the test:

----------------------------------------------------------------------------------------------
Sub MergeTest()
Const MMMDoc = "C:\temp\TestDoc.doc"
Const DataFile = "C:\temp\TestData.edc"
Dim MergeDoc As Document

Set MergeDoc = Documents.Open(MMMDoc)

With ActiveDocument.MailMerge
.MainDocumentType = wdFormLetters
.SuppressBlankLines = True
.OpenDataSource Name:=DataFile, _
Format:=wdOpenFormatText, _
ConfirmConversions:=False, _
ReadOnly:=True, _
LinkToSource:=False
.Execute
End With
End Sub
----------------------------------------------------------------------------------------------

The data file is a tilde-delimited text file.

Thanks.

Ed







Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Automated Mail Merge With Excel Sheet containing data. ksg Mailmerge 5 March 8th 07 07:54 AM
Automated Mail Merge Displaying unwanted Dialog Boxes ksg Mailmerge 8 January 14th 07 03:13 PM
Automated Mail Merge "Now Printing Page " Boxes ksg Mailmerge 1 January 12th 07 06:25 PM
Automated mail merge of catalog/directory inserts page breaks Tim Mailmerge 2 July 28th 06 07:45 PM
Insert Merge Field problem with Word-Mail Merge from Excel documen Augusta E. Microsoft Word Help 2 June 20th 05 10:59 AM


All times are GMT +1. The time now is 11:09 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"