Hi =?Utf-8?B?QmV2?=,
> I am trying to merge individual records separately into separate documents,
> so I've written a looping macro which merges each record separately and loops
[quoted text clipped - 6 lines]
> occasionally gives the right record count, but not reliably. It quite often
> gives only 1 as the number as well. What am I doing wrong?
Impossible to say without seeing the code.
Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org
This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :-)
Bev - 12 Jun 2005 22:55 GMT
Hi Cindy
The Code I've written is:
WordBasic.Call "SaveMergePractice"
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
With .DataSource
.FirstRecord = 1
.LastRecord = 1
End With
.Execute Pause:=False
End With
ActiveWindow.Close
' This loops through all filtered records and merges single
' record at a time to a new document, ready for calculating
rn = 1 ' rn = record number
Do
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
With .DataSource
.FirstRecord = rn
.LastRecord = rn
End With
.Execute Pause:=False
End With
Windows("2BMerged.doc").Activate
rn = rn + 1
Loop Until (rn > ActiveDocument.MailMerge.DataSource.RecordCount)
End Sub
Is the problem in this code or perhaps in some way I'm accessing the mail
merge
data source?
> Hi =?Utf-8?B?QmV2?=,
>
[quoted text clipped - 18 lines]
> This reply is posted in the Newsgroup; please post any follow question or reply
> in the newsgroup and not by e-mail :-)
Cindy M -WordMVP- - 13 Jun 2005 10:06 GMT
Hi =?Utf-8?B?QmV2?=,
> Is the problem in this code or perhaps in some way I'm accessing the mail
> merge
> data source?
It's possible, hard to say.
1. What's the data source?
2. What connection method was used to attach it?
3. If you just work with the data source in a mail merge document are you
able to see and select all the records?
Note: on both my website and word.mvps.org you'll find alternate approaches
for "pulling apart" a mail merge result. You might want to look at those.
Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org
This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :-)
Bev - 13 Jun 2005 22:00 GMT
Hi Cindy - To answer your questions, I connected to the data source manually
through Word in the usual manner, using the Mail Merge Helper. The data
source is a Word document. When I just work on the data source manually
within Word I can see all the records. VBA can name the drive path of the
data source, giving it to me in a message box if I ask it, but
programmatically, it cannot detect the right number of records and the code I
wrote just stops after merging the first record.
I've been looking at this discussion group over the last week and have found
a couple of different ways around the problem. I think I might use the
Splitter macro written by Doug Robbins and modified by Graham Mayor and maybe
even use the Throw Away macro by Doug Robbins, because I was wanting to use
data source information in the save name of the separate documents.
Thanks for your help. This discussion group is really helpful. There's
always someone who's already asked almost exactly the same questions before.
I've learnt a lot from just browsing.
> Hi =?Utf-8?B?QmV2?=,
>
[quoted text clipped - 21 lines]
> This reply is posted in the Newsgroup; please post any follow question or
> reply in the newsgroup and not by e-mail :-)