Mail Merge Automation to Word 2000

C

chrisa

Hi,

I am trying to automate a mail merge between Delphi and Word 2000.
Code below :

wrdApp := CreateOleObject('Word.Application');
wrdApp.Visible := FALSE;
wrdApp.Documents.Open(TemplateName);
wrdApp.ActiveDocument.MailMerge.OpenDataSource(Name :=
DataSourceName);
wrdApp.ActiveDocument.MailMerge.Destination :=
wdSendToNewDocument;
wrdApp.ActiveDocument.MailMerge.MainDocumentType := wdFormLetters;
wrdApp.ActiveDocument.MailMerge.Execute(False);

I am receiving an error on the Execute : "This method or property is
not available because the current mail merge main document needs a
data source.". So I did a bit of research and found out that the data
source is being removed coz of a security update. So I set
wrdApp.DisplayAlerts to wdAlertsShowAll but it still doesn't show the
message and therefore still fails. I found a reg hack listed by
Microsoft but it doesn't work for anything lower that Word 2003.

Btw, this code works fine in Word 2007. Any ideas???

Cheers,

Chris.
 
C

Cindy M.

So I did a bit of research and found out that the data
source is being removed coz of a security update.
There haven't been any security updates for Word 2000 for
some years. Can you point us to this source?

Do you get anything different if you set the application.
Visible to True, rather than False?

The following seems a bit odd to me:
wrdApp.Documents.Open(TemplateName);

Are you actually opening a template? Shouldn't you be using
the Documents.Add method with a template?

And I advise you to set this to a document object variable
as it's created. Better to work with that then always rely
on ActiveDocument, especially with mail merge that will
generate additional documents. In C# pseudocode that would
be:
Word.Document wdDoc = wdApp.Documents.Add
(TemplateName);

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