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 2004

Tip: Looking for answers? Try searching our database.

Multipe Merges of data

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mike Moschella - 14 Jun 2004 21:59 GMT
I am tring to increase the speed of my code that does a
number of merges of datasource data.  One way I think I
can get a speed up is to not close the template file in
between the merges. But when I try to Kill
the  "C:\DataSource.dat" basic says the file is still in
use.  How do I release the file so that I can delete it so
that I can create and attach a new data source file for
the template to use in a merge?

    Set mDoc = mWrd.Documents.Open
("C:\TempTemplate.doc")
       Set mTempDoc = mWrd.ActiveDocument
       Do WHile(more merges to do)
        Call CreateDataSource
           mDoc.MailMerge.MainDocumentType =
wdFormLetters
           mDoc.MailMerge.OpenDataSource
Name:="C:\DataSource.dat"
           mWrd.Visible = True
           mWrd.Activate                
        mDoc.MailMerge.Destination =
wdSendToNewDocument
           mDoc.MailMerge.Execute
           Set mMergeDoc = mWrd.ActiveDocument
           mMergeDoc.Activate
                 mMergeDoc.Saved = True
               mMergeDoc.Close
               Set mMergeDoc = Nothing
        Kill "C:\DataSource.dat"
       loop
       mDoc.Saved = True
       mDoc.Close
       Set mDoc = Nothing
       Set mTempDoc = Nothing

The Code below works fine I can delete the DataSource File
and createa new one and use it fo the next merge but I
don't want to keep opening and closing the template file
which takes time for each new merge since they all use the
same temeplate file, I want to delete the datasource file
and create a new one and use that.

       Do WHile(more merges to do)
         Set mDoc = mWrd.Documents.Open
("C:\TempTemplate.doc")
           Set mTempDoc = mWrd.ActiveDocument
        Call CreateDataSource
           mDoc.MailMerge.MainDocumentType =
wdFormLetters
           mDoc.MailMerge.OpenDataSource
Name:="C:\DataSource.dat"
           mWrd.Visible = True
           mWrd.Activate                
        mDoc.MailMerge.Destination =
wdSendToNewDocument
           mDoc.MailMerge.Execute
           Set mMergeDoc = mWrd.ActiveDocument
           mMergeDoc.Activate
                 mMergeDoc.Saved = True
               mMergeDoc.Close
               Set mMergeDoc = Nothing
           mDoc.Saved = True
           mDoc.Close
           Set mDoc = Nothing
           Set mTempDoc = Nothing       
        Kill "C:\DataSource.dat"
    loop

Mike
Peter Jamieson - 15 Jun 2004 08:17 GMT
Try unlinking the mailmerge main document from the datasource before
deleting the data source, e.g. via

mDoc.MailMerge.MainDocumentType = wdNotAMergeDocument

Signature

Peter Jamieson

> I am tring to increase the speed of my code that does a
> number of merges of datasource data.  One way I think I
[quoted text clipped - 65 lines]
>
> Mike
- 16 Jun 2004 21:35 GMT
Worked great thanks

Mike
>-----Original Message-----
>Try unlinking the mailmerge main document from the datasource before
[quoted text clipped - 73 lines]
>
>.
 
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.