Reply
 
Thread Tools Display Modes
  #1   Report Post  
Bev
 
Posts: n/a
Default 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   Report Post  
Cindy M -WordMVP-
 
Posts: n/a
Default

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   Report Post  
Bev
 
Posts: n/a
Default

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   Report Post  
Cindy M -WordMVP-
 
Posts: n/a
Default

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   Report Post  
Bev
 
Posts: n/a
Default

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

Posting Rules

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Detaching a MailMerge Data Source Meena Bhashyam Mailmerge 1 April 20th 05 05:47 PM
Formatting a word mailmerge with Excel data source Tracey Mailmerge 2 March 15th 05 02:07 PM
Specific Email Merge w/ Specific Attachements Mark B Mailmerge 9 February 21st 05 05:10 AM
Mailmerge data source in an Access database will not open Colin C Mailmerge 3 December 31st 04 12:01 AM
Mailmerge wont see Added Excel Data source Columns Thatdampwood Mailmerge 3 December 2nd 04 10:56 PM


All times are GMT +1. The time now is 04:03 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"