Home |
Search |
Today's Posts |
#1
|
|||
|
|||
mailmerge cannot read data source
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 according to the record count of the data source. It worked fine when we were using Word 97 but I've had problems since I re-wrote it in Word 2003. To start with it was losing connection with the server, but applying the latest Office service patch fixed that one. But now, whenever I revisit the data source to add more records VBA only lists there being 1 record in the data source. Using the code ActiveDocument.MailMerge.DataSource.LastRecord 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? |
#2
|
|||
|
|||
Hi ?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 according to the record count of the data source. It worked fine when we were using Word 97 but I've had problems since I re-wrote it in Word 2003. To start with it was losing connection with the server, but applying the latest Office service patch fixed that one. But now, whenever I revisit the data source to add more records VBA only lists there being 1 record in the data source. Using the code ActiveDocument.MailMerge.DataSource.LastRecord 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 :-) |
#3
|
|||
|
|||
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? "Cindy M -WordMVP-" wrote: Hi ?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 according to the record count of the data source. It worked fine when we were using Word 97 but I've had problems since I re-wrote it in Word 2003. To start with it was losing connection with the server, but applying the latest Office service patch fixed that one. But now, whenever I revisit the data source to add more records VBA only lists there being 1 record in the data source. Using the code ActiveDocument.MailMerge.DataSource.LastRecord 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 :-) |
#4
|
|||
|
|||
Hi ?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 :-) |
#5
|
|||
|
|||
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. "Cindy M -WordMVP-" wrote: Hi ?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 :-) |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Detaching a MailMerge Data Source | Mailmerge | |||
Formatting a word mailmerge with Excel data source | Mailmerge | |||
Specific Email Merge w/ Specific Attachements | Mailmerge | |||
Mailmerge data source in an Access database will not open | Mailmerge | |||
Mailmerge wont see Added Excel Data source Columns | Mailmerge |