<<
Do you think I might need to create another macro for AutoClose() to
reset the SELECT statement or something?
Well, AutoClose does /a/ job, but if you do the following
Save a document (say mydoc.doc)
Save As the same document (say mydoc1.doc)
Close the document
then AutoClose only "fires" for mydoc1.doc
To catch every "Save" event you really need to use the Application Event
DocumentBeforeSave (in Word 2000 and later). It's not something I've gone
into in any depth but there's a useful page at
http://word.mvps.org/faqs/macrosvba/AppClassEvents.htm
However, because this is an /Application/ event, it will apply to every
document. Unless you want to disconnect the data source for /every/ mail
merge main document (personally, as a user I don't take kindly to having the
default behaviour of Word altered) then you really need to put something in
the document that the event handler can test to see if it should detach the
data source. It could be a document variable, something in the body of the
document, a document property etc.
I would use
Doc.MailMerge.MainDocumentType = wdNotAMergeDocument
to disconnect the data source. Although there's a DataSource.Close method,
a. you need to test that the DataSource object exists before you invoke it
(actually, making that test is another VBA question I don't know the best
answer to but I think you have to do something like
On Error Resume Next
If Not IsNull(Doc.MailMerge.DataSource) Then
Doc.MailMerge.MainDocumentType = wdNotAMergeDocument
End If
b. it's not very helpful because if you use it, then close the document,
that SQL prompt still pops up when you re-open even though the data source
is not actually re-opened.
<<
By the way my surname is Jamieson too
> ... SPOOKY ... could be related ???
:-) If you or your Jamieson ancestors are from Shetland then it's possible -
you can always have a look around http://www.bayanne.info/Shetland
Peter Jamieson
> Peter,
> Thank you for your response and help. By the way my surname is Jamieson
[quoted text clipped - 104 lines]
>> > I have searched the internet for a possible solution but have not found
>> > anything? Any ideas?