Preventing mailmerge "select data source" dialog

G

Gabriele Nazeri

Hello.
I need to prevent the "select data source" dialog from displaying when I
open a mailmerge document from my code. It doesn't matter if it's VB, VCS or
VC++.
For example, I have a word document that is connected to an Excel data
source. When I open the file with something like "wrdApp.Documents.Open" it
shows the dialog, while I need it to be fully automated. At the moment I
noticed that I can make it work by "simulating" escape key by trapping the
dialog window and sending a WM_KEY message. But I think this is a bad
approach (I have to check the window caption and obviously it doesn't work if
I check for the caption in a language different from that in which Office is
installed).
I tried to record a macro when opening a mailmerge file but it shows nothing
useful (only "ChangFileDirectory" actually).
Anyone who can help me? Thanks a lot and sorry if I wrote too much.

Gabriele.
 
C

Cindy M.

Hi =?Utf-8?B?R2FicmllbGUgTmF6ZXJp?=,

Which version of Word are we dealing with?
I need to prevent the "select data source" dialog from displaying when I
open a mailmerge document from my code. It doesn't matter if it's VB, VCS or
VC++.
For example, I have a word document that is connected to an Excel data
source. When I open the file with something like "wrdApp.Documents.Open" it
shows the dialog, while I need it to be fully automated. At the moment I
noticed that I can make it work by "simulating" escape key by trapping the
dialog window and sending a WM_KEY message. But I think this is a bad
approach (I have to check the window caption and obviously it doesn't work if
I check for the caption in a language different from that in which Office is
installed).
I tried to record a macro when opening a mailmerge file but it shows nothing
useful (only "ChangFileDirectory" actually).
Anyone who can help me? Thanks a lot and sorry if I wrote too much.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 
G

Gabriele Nazeri

Cindy M. said:
Hi =?Utf-8?B?R2FicmllbGUgTmF6ZXJp?=,

Which version of Word are we dealing with?

Hi, we're using Word 2003.
I was also wondering if there is some way to obtain the path of the linked
data source without opening the document with OLE. Knowing that I could try
and make a directory that's the same as the path where the data source was.
Word would find the file and wouldn't ask me where it is.

Thanks,
Gabriele Nazeri.
 
C

Cindy M.

Hi =?Utf-8?B?R2FicmllbGUgTmF6ZXJp?=,
we're using Word 2003.
OK, in that case this indicates that the *connection* information you're
passing in the OpenDataSource method isn't adequate. Something's missing, so
Word is prompting.

What's the data source? Have you tried recording linking in the data source in
a macro, then comparing the connection information in the recorder's
OpenDataSource with what you're using?
I was also wondering if there is some way to obtain the path of the linked
data source without opening the document with OLE. Knowing that I could try
and make a directory that's the same as the path where the data source was.
Word would find the file and wouldn't ask me where it is.
That wouldn't work. The Security in Word 2003 automatically detaches the data
source from a merge document when it's opened using automation. But to answer
the question: you can get this only if the document has been saved in Word
2003 XML file format; you can't get it out of the binary file.
I need to prevent the "select data source" dialog from displaying when I
open a mailmerge document from my code. It doesn't matter if it's VB, VCS or
VC++.
For example, I have a word document that is connected to an Excel data
source. When I open the file with something like "wrdApp.Documents.Open" it
shows the dialog, while I need it to be fully automated. At the moment I
noticed that I can make it work by "simulating" escape key by trapping the
dialog window and sending a WM_KEY message. But I think this is a bad
approach (I have to check the window caption and obviously it doesn't work if
I check for the caption in a language different from that in which Office is
installed).
I tried to record a macro when opening a mailmerge file but it shows nothing
useful (only "ChangFileDirectory" actually).

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
C

Cindy M.

Hi =?Utf-8?B?R2FicmllbGUgTmF6ZXJp?=,

If you use the Documents.Open method to open a mail merge document in Word 2003 it
should automatically remove the reference to the data source and not present a
dialog box at all. I can only imagine that you may have set the Registry key to
disable the security option that would do this...

Try using Application.DisplayAlerts and turn off the alerts.
I'm sorry but it looks like I couldn't explain the problem in a proper way.
I'm not using the OpenDataSource method. I have a bunch of .doc and .xls
files that my customers send to me via e-mail. If I open one of those files
by double-clicking on it word says that it's part of a mail-merge document,
so it prompts me to select where the .xls file is located.
What I need is that word does NOT prompt me to select anything. I need to do
a batch conversion (we're talking about hundreds of mailmerge documents every
day).
To do that I have a Visual C++ (.NET 2005) that opens a Word OLE object and
opens the document. A specific thread monitors the dialogs coming from word
and "simulates" the press of the escape key to dismiss the dialog. What I
want is to stop using that thread, because... well, it's really a terrible
workaround :) (And I've got serious doubts it'll keep working when we'll
switch to Office 2007)


Actually, I've tried to do just that and it works, that's why I asked how to
get the path :)
I mean: I made a mail-merge document with the word 2003 wizard, linking to
an .xls file. I copied the .doc file to another PC and it obviously asked me
the path to the .xls file. I closed word, put the .xls file in a directory
with the same name, path and drive as the one on the PC where it was created
and double-clicked the word document. It opened just fine, with no dialogs.
But of course, that little experiment is useless if I can't obtain the path
from the binary file.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply in
the newsgroup and not by e-mail :)
 
G

Gabriele Nazeri

Hi,
If you use the Documents.Open method to open a mail merge document in Word 2003 it
should automatically remove the reference to the data source and not present a
dialog box at all. I can only imagine that you may have set the Registry key to
disable the security option that would do this...

I didn't even know there was a Registry Key to set. I had a look into the
Registry but I couldn't figure out, which one is it?
Try using Application.DisplayAlerts and turn off the alerts.

I tried that as one of my first options, but it didn't work. After some
search on the net I read that in word 2003 that setting doesn't work as fine
as it used to work in previous word versions.
I also tried to lower the security level (from the "Macro" menu) and it
actually became worse, because it asked me confirmation to execute the select
from an external file, then if didn't find it and asked me to set the path to
the data source, and then the usual "select data source" dialog appeared.
I must admit I've got no more ideas :)

Regards,
Gabriele.
 
C

Cindy M.

Hi =?Utf-8?B?R2FicmllbGUgTmF6ZXJp?=,
I didn't even know there was a Registry Key to set. I had a look into the
Registry but I couldn't figure out, which one is it?
http://support.microsoft.com?kbid=825765


I tried that as one of my first options, but it didn't work. After some
search on the net I read that in word 2003 that setting doesn't work as fine
as it used to work in previous word versions.
That's very odd, because until Word 2002 it didn't work at all to suppress mailmerge
alerts... Can you give me a URL to the information you saw?
I also tried to lower the security level (from the "Macro" menu) and it
actually became worse, because it asked me confirmation to execute the select
from an external file, then if didn't find it and asked me to set the path to
the data source, and then the usual "select data source" dialog appeared.
I must admit I've got no more ideas :)
that permission to execute the sql is the KB article link I referred you to.

I just ran a quick test using C# (VS 2005 + Office 2003) and I can't duplicate your
problem. When I use the Documents.Open method to open a mail merge document with a
linked Excel sheet the link is removed. No questions asked. And I'd expect this to
happen even if the Excel sheet were available. This was implemented in Word 2002
(unlinking the data source) and I can't imagine why you'd see something different...

Which "flavor" of Office 2003 are you working with? Check the information in
Help/About.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply in the
newsgroup and not by e-mail :)
 
G

Gabriele Nazeri

Hi,

I checked the "SQLSecurityCheck" and it was already set to 0. I tried
setting it to 1, and it did show the confirmation dialog about executing SQL,
so I guess 0 is the right value for me.
But unfortunately that doesn't remove the "Select data source" dialog.
It definitely looks like word doesn't remove the link to the data source.
That's very odd, because until Word 2002 it didn't work at all to suppress mailmerge
alerts... Can you give me a URL to the information you saw?

I haven't been able to find that link again, but I found a post from you
that dates back to 2004, where you were answering to exactly the same problem
I have now:
http://www.officekb.com/Uwe/Forum.aspx/word-mailmerge/3362/AVOIDING-Select-Data-Source-dialog-box
So it looks like I didn't search deep enough but post that doesn't solve my
problem either.
Which "flavor" of Office 2003 are you working with? Check the information in
Help/About.

The information in Help/About reads:
Microsoft(r) Office Word 2003 (11.8106.8107) SP2

Gabriele.
 
C

Cindy M.

Hi Gabriele,
I found a post from you
that dates back to 2004, where you were answering to exactly the same problem
I have now:
http://www.officekb.com/Uwe/Forum.aspx/word-mailmerge/3362/AVOIDING-Select-Data-Sourc
e-dialog-box
Wow, I'd forgotten all about that discussion... And re-reading it doesn't ring any
bells, I'm afraid. I can't remember at all what I was seeing at the end of that
conversation <sigh>, and my quick test for you didn't reproduce the behavior you're
seeing (with Office 2003 SP2).

So the only straw to grasp at that I see (with the exception of your opening a
support case with Microsoft) is: 1. how the Excel file is generated and 2. How it's
linked to the Word document. Do you have any information or influence on that?

What do you have to do with these Word documents, once you've opened them?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply in
the newsgroup and not by e-mail :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top