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 / Programming / December 2004

Tip: Looking for answers? Try searching our database.

Clearing Merge Data Source and Merge FIle

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Shane Buchholz - 30 Nov 2004 19:11 GMT
I have created a Word document that pulls data from a database, writes
that data to a text file and then uses that file as the datasource for
a mail merge. I have set the code up to delete and recreate the source
file whenever the form is run so that I only get current data. The
form is doing what I want it to, save one thing: the source file
becomes associated with the main document during the merge process. If
I try to run the form again to get new data, I get a "permission
denied" error when the code tries to delete the old source file.

Does anyone know how to disassociate the source file from the main
document in VBA. I can do it manually, but I am going to release this
to a non-technical user and I would like the process to be seamless.
The "manual way" is to close the document, delete the source file and
then re-open the document.  At this point Word tells you the source
file no longer exists and gives you the option of removing the
data/header source.  I created a macro to record the steps when I
re-open the file, and remove the data/header information but that was
not helpful.  Thanks in advance.

Richard O'Neil
Doug Robbins - 01 Dec 2004 02:18 GMT
Probably:

ActiveDocument.MailMerge.MainDocumentType = wdNotAMergeDocument

Signature

Please respond to the Newsgroup for the benefit of others who may be
interested.   Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP

>I have created a Word document that pulls data from a database, writes
> that data to a text file and then uses that file as the datasource for
[quoted text clipped - 16 lines]
>
> Richard O'Neil

Rate this thread:






 
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.