Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
[email protected] jamiechen168@gmail.com is offline
external usenet poster
 
Posts: 6
Default Find out what data source the document is using?

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;

  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default Find out what data source the document is using?

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

--
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

wrote in message
ups.com...
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;



Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Finding a document attached to a data source Carol Microsoft Word Help 0 August 22nd 06 02:43 PM
Word 2003 Mail Merge Problem when E-Mailing Data Source Karen Townsend Mailmerge 3 June 20th 06 08:21 AM
Mail Merge can't find data source in Office XP...but it could in 2000! [email protected] Mailmerge 4 June 7th 06 03:15 PM
Word cannot find data source Recorder Mailmerge 1 January 26th 06 09:29 AM
Data Form button Carla Bradley Mailmerge 5 April 26th 05 07:14 PM


All times are GMT +1. The time now is 02:39 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"