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 / Mailmerge and Fax / May 2004

Tip: Looking for answers? Try searching our database.

AVOIDING "Select Data Source" dialog box?!?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Alessio - 24 May 2004 09:20 GMT
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
Cindy M  -WordMVP- - 24 May 2004 15:38 GMT
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,
[quoted text clipped - 3 lines]
> 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 :-)
Alessio - 25 May 2004 08:39 GMT
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

> Hi Alessio,
>
[quoted text clipped - 20 lines]
> This reply is posted in the Newsgroup; please post any follow question
> or reply in the newsgroup and not by e-mail :-)
Cindy M  -WordMVP- - 25 May 2004 16:07 GMT
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 :-)
Alessio - 26 May 2004 08:50 GMT
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

> Hi Alessio,
>
[quoted text clipped - 20 lines]
> This reply is posted in the Newsgroup; please post any follow question
> or reply in the newsgroup and not by e-mail :-)
Cindy M  -WordMVP- - 26 May 2004 16:26 GMT
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 :-)
 
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.