AVOIDING "Select Data Source" dialog box?!?

A

Alessio

Hello,
my problem is very simple, yet it seems not to have a solution.
It happens with a certain Word2003 mailmerge document: I open it using
Word2003 (through OLE), and a "Select Data Source" dialog box appears,
asking me to specify the data source path. If I manually cancel that
dialog box, then everything seems to work as usual (i.e., as Word2000
usually behaves), and the automation code works.
But, HOW CAN I AVOID THAT DIALOG BOX ?!?!? IT MAKES THE AUTOMATION
CODE HANG!!!
Please note: the dialog box I'm talking about is not the one carrying
the two buttons "Finds data source..." and "Options..."; it is an
open-file-style dialog.
Thank you very much, and more
have a nice day
Alessio
 
C

Cindy M -WordMVP-

Hi Alessio,

Please post the OpenDataSource method's code you're trying to use.

Note that there was a very important change in this method's syntax
starting with Word 2002. So you probably will need to either have two
procedures (one for 2000/97, another 2002 and later) or you will have to
use late binding for the Word object model.
It happens with a certain Word2003 mailmerge document: I open it using
Word2003 (through OLE), and a "Select Data Source" dialog box appears,
asking me to specify the data source path. If I manually cancel that
dialog box, then everything seems to work as usual (i.e., as Word2000
usually behaves), and the automation code works.
But, HOW CAN I AVOID THAT DIALOG BOX ?!?!? IT MAKES THE AUTOMATION
CODE HANG!!!

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
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 :)
 
A

Alessio

Hi Cindy,
the point is that I'm not trying to open the data source. The method
I'm using, causing that dialog box to appear, is the Open method of a
Documents object (it's a VC++.NET application). Here's the code of the
Open method:
....
oDoc = m_oDocs.Open( COleVariant( szPath ), // name
vtFalse, // ConfirmConversions
vtFalse, // ReadOnly
vtFalse, // AddToRecentFiles
vtOpt, // PasswordDocument
vtOpt, // PasswordTemplate
vtTrue, // Revert
vtOpt, // WritePasswordDocument
vtOpt, // WritePasswordTemplate
COLeVariant( 1L ),// Format = OpenFormatDocument
vtOpt, // Encoding
vtTrue, // Visible
vtFalse, // OpenAndRepair
vtOpt, // DocumentDirection
vtTrue, // NoEncodingDialog
vtOpt ); // XMLTransform

I suspect that it's that particular Word document causing this
(strange, I think) behaviour. But I'd like to be able to manage it...
I mean, I have to!

Thank you
Alessio
 
C

Cindy M -WordMVP-

Hi Alessio,
the point is that I'm not trying to open the data source. The method
I'm using, causing that dialog box to appear, is the Open method of a
Documents object (it's a VC++.NET application).
Ah, OK. Then the document doesn't "find" the data source; the cause of
this can vary, but that's no the important point, in your case...

Try setting the DisplayAlerts property of the Word application object
to "none" (it's a LONG value or a wd-enumeration constant, there are
three possibilities for the property)

Note, also, that this doesn't work for all earlier versions of Word.
Definitely not for 97; I can't remember exactly for 2000, but I think
not; should for 2002 and 2003)

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
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 :)
 
A

Alessio

Hi Cindy,
unfortunately I already set the DisplayAletrs property to none, but to
no avail.
I really think that the problem is in the document itself, and I
suspect that it depends on HOW the document was originally created.
(Unfortunately, I can't contact the author.)
Perhaps the following behaviours can help you find a solution; here is
what happens when I open the document MANUALLY:
First the "Select data source" dialog box appears.
1) If I select the data source file and confirm the dialog, then the
document is opened (along with the data source), and nothing more
happens (i.e., I can browse the mailmerge records, print them and do
anything I want, without being asked for anything else).
2) If I Cancel the dialog, then the usual dialog box carrying the two
buttons "Find data source..." and "Options..." is displayed; if I
choose "Find data source..." then the previous "Select data source"
dialog box appears, but when I select the same data source as in point
1, another dialog box is displayed: the "Select table" dialog box,
showing the following 6 items:

Sheet1$
Sheet1$Query_from_PRODXPDB_1
Sheet1$Query_from_PRODXPDB_2
Sheet1$Query_from_PRODXPDB_3
Sheet2$
Sheet3$

I choose Sheet1$, and everything works fine. So, what's the reason why
these two different behaviours occur? Does it helps you understanding
what's going on?

Thank you
Alessio
 
C

Cindy M -WordMVP-

Hi Alessio,
unfortunately I already set the DisplayAletrs property to none, but to
no avail.
The behavior you describe is well-known to me, and there are a number of
factors that could be the basic cause. But none of that is probably
going to be of much help to you, unless you can influence how these
kinds of files are going to be coming to you?

I just tested DisplayAlerts on a "forced case" in Word 2003 with an SP
beta and I see something else (even worse than you report).

At this point, the best I can do is point you to a Knowledge Base
article written originally for VB. It uses a Timer to "SendKeys" to an
application to dismiss the dialog box "hanging" it. Not a pretty sight,
but the only possibility. Try a Search on
"How to" AND "Office" AND "dismiss" AND "message"

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
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