View Single Post
  #9   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Losing MainDocumentType on Open()

Is there any other work a rounds for this?

As far as I know the only alternative based on Word's built-in Mail merge
is to have a mail merge main document that does not have a SQL command
stored in it. That possibility was explored in this group a year or two ago
but
a. it involved saving the Word document in rtf format and patching the rtf
code to remove the SQL statement
b. it could only work with a data source where Word would correctly
regenerate the required SQL statement
c. I suspect that one of the later SPs has blocked that particular loophole

Precisely why it more insecure for a document to connect to a data source
than to have a situation where you have no alternative but to implement this
registry patch is not clear to me.

--
Peter Jamieson
http://tips.pjmsn.me.uk

"Jerry" wrote in message
...
Hi Peter, this does seem to work, but I'm not sure it is a viable solution
for me. Is there any other work a rounds for this?


Thanks,

Jerry

"Peter Jamieson" wrote:

You probably need to make the registry change described in the following
KB
article:

http://support.microsoft.com/kb/825765/en-us

If you don't, when you open the Word document in code, the data source is
diconnected and the document that is supposed to be a Mail merge Main
Document becomes a Normal Word Document.

--
Peter Jamieson
http://tips.pjmsn.me.uk

"Jerry" wrote in message
...
Hey guys, I have a mail merge document that is set to Directory for the
Main
Document Type. If I close it and manually reopen it, it stays as a
"Directory" document, but if I open it through automation (i.e.
oWord.Documents.Open("C:\SomeDirectory\SomeDirecto ryDocument.doc")) the
oWord.ActiveDocument.MailMerge.MainDocumentType = -1 as soon as you do
the
Open() command and then it gets set to 0 once you call the
OpenDataSource().

How can I open the document through automation and keep the document
type
that the user originally saved it with?


Thanks for your help,

Jerry