Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Mailmerge and Fax / June 2005

Tip: Looking for answers? Try searching our database.

mailmerge cannot read data source

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bev - 09 Jun 2005 21:56 GMT
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?
Cindy M  -WordMVP- - 10 Jun 2005 08:37 GMT
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 :-)
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.