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 / September 2006

Tip: Looking for answers? Try searching our database.

Find out what data source the document is using?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jamiechen168@gmail.com - 22 Sep 2006 20:35 GMT
Hello,

As you know if you open a Word document which has Mail Merge fields,
Word will ask you "...Opening this document will run the following SQL
command: SELECT * FROM ..".

I am writing code which needs to analyze a Word document and to
identify the data source used for this document, but couldn't find a
resolution. Can someone give me a clue how we can fetch the name of
Data Source?

Thanks

Below is my pseudo code (C#) looks like?

// Create a Word App obj
myWordApp = new Word.ApplicationClass();

// Load the word document file
String wordFile = "c:\\temp\\test.doc";
bject missing = System.Reflection.Missing.Value;
Word.Document myWordDoc = myWordApp.Documents.Add(ref wordFile, ref
missing, ref missing, ref missing);

// See if we can find out the data source. However dataSource is empty
String dataSource = myWordDoc.MailMerge.DataSource.ConnectString;
Doug Robbins - Word MVP - 23 Sep 2006 05:20 GMT
Not sure why you want to identify the source, but the following article
gives a method of preventint the display of the message,

"Opening This Will Run the Following SQL Command" Message When You Open a
Word Document - 825765 at:

http://support.microsoft.com?kbid=825765

After making that modification, it should result in the document opening
with the data source attached to it and then in then (in vba) you could use:

    ActiveDocument.MailMerge.DataSource.Name

Can't help with the C# code

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

> Hello,
>
[quoted text clipped - 22 lines]
> // See if we can find out the data source. However dataSource is empty
> String dataSource = myWordDoc.MailMerge.DataSource.ConnectString;

Rate this thread:






 
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.