If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Multipe Merges of data
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 |
#2
|
|||
|
|||
Multipe Merges of data
Try unlinking the mailmerge main document from the datasource before
deleting the data source, e.g. via mDoc.MailMerge.MainDocumentType = wdNotAMergeDocument -- Peter Jamieson "Mike Moschella" wrote in message ... 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 |
#3
|
|||
|
|||
Multipe Merges of data
Worked great thanks
Mike -----Original Message----- Try unlinking the mailmerge main document from the datasource before deleting the data source, e.g. via mDoc.MailMerge.MainDocumentType = wdNotAMergeDocument -- Peter Jamieson "Mike Moschella" wrote in message ... 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 . |
Thread Tools | |
Display Modes | |
|
|