DataSource is unavailable in Word 2003

A

Amanda

I write an application using VB6. With Word 2003, I
cannot identify the datasource used when creating the
original mail merge document. (The original document can
have a datasource named anything under the sun. I do not
control the naming from the VB app.) With Word 97, 2000,
and 2002, I can get this information. With Word 2003, it
comes out empty. Here's an example of basic code to
reproduce this. Is there a different way of doing this?
(Alas, I need to control the merge from VB, NOT from Word
for my purposes, and I have no way of guaranteeing what
the datasource is named, so I need to be able to retrieve
it from the document.)

'dim variable here
Set WdDoc = WdApp.Documents.Open
("C:\somedirectory\Test1.doc")
SourceName = WdDoc.MailMerge.DataSource.Name

Note that the document referenced was created in MSWord
2003 using the "Type New List' option, selecting
the 'customize' option and creating a few of my own field
names. (F_AddressName, for example).

Thanks for any input!
A.
 
P

Peter Jamieson

Here's an example of basic code to
reproduce this. Is there a different way of doing this?
(Alas, I need to control the merge from VB, NOT from Word
for my purposes, and I have no way of guaranteeing what
the datasource is named, so I need to be able to retrieve
it from the document.)

Word 2003 has added a security check on the data source - basically, if it
thinks it's going to have to execute SQL (which is "almost always" when the
document is a mail merge main document), Word will pop up a dialog box when
the user opens a mail merge main document.

When you are opening the document programmatically, Word will just discard
the mailmerge datasource without warning (and you may see that referencing
WdDoc.MailMerge.DataSource.QueryString will probably generate an error)
/unless/ you use (say)

WdApp.DisplayAlerts = wdAlertsMessageBox

in which case the user is prompted when the document opens.

As far as I know the only other way you might be able to work around this
would be to follow

http://support.microsoft.com/default.aspx?scid=kb;en-us;825765

on each machine your code runs on.
 
A

Amanda

Thank you! We are one of the apparent few who are NOT
executing SQL statements with the merge. (we builde an
external file and it, in its entirety, is the mail
merge.) We'll implement the message by default and give
the users the option of changing settings and addressing
it at each workstation. (I think I'm on the path to
liking WordPerfect more and more each day.)

Thanks again!
A.
 

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