Board index » delphi » Simple Word 97, 2000 and XP automation

Simple Word 97, 2000 and XP automation

I want my program to support simple automation (mail merging, filling fields
etc) for Word 97, 2000 and XP (2002) with Delphi 5.

The question is : how do I support all of these without knowing which
version a client has installed?

I've tried using the D5 server components for 97 which work with 2000 and
97, but the "Server throws an exception" on XP.

Presumably, I must use LATE binding to allow for the different versions (?),
but again I have problems with XP.

Any suggestions / examples would be greatly appreciated (I've looked at
Deborah Pate's site which has been very helpful).

TIA,

Hedley Muscroft
Pioneer Software Ltd

 

Re:Simple Word 97, 2000 and XP automation


<<Hedley Muscroft:
I've tried using the D5 server components for 97 which work
with 2000 and 97, but the "Server throws an exception" on
XP.

Quote

At what point, exactly? The components for Word 97 /should/
be compatible with later versions of Word.

--
Deborah Pate (TeamB) http://delphi-jedi.org

  TeamB don't see posts sent via Google or ISPs
  Use the real Borland server: newsgroups.borland.com
  http://www.borland.com/newsgroups/genl_faqs.html

Re:Simple Word 97, 2000 and XP automation


Deborah,

I have two components on my form (TWordApplication and TWordDocument).

Here's my code :-
-------------------------------------
procedure TMainForm.LaunchWordLetter(FileName : OleVariant);
var
  FieldName : OleVariant;
begin
  FileName := IncludeTrailingBackslash(FDatabaseDir) + 'Docs\' + FileName;
  WordDocument.ConnectTo(WordApplication.Documents.Add(FileName, EmptyParam));
  WordApplication.Visible := true;

//other stuff...
end;
-------------------------------------

It's the WordDocument.ConnectTo line that fails on XP but works fine with 2000.

I noticed in another thread that someone had similar problems with XP and if they put in a Sleep(2000) it worked(?).

Thanks.

"Deborah Pate (TeamB)" <d.p...@blueyonder.co.not-this-bit.uk> wrote:

Quote
><<Hedley Muscroft:
>I've tried using the D5 server components for 97 which work
>with 2000 and 97, but the "Server throws an exception" on
>XP.

>At what point, exactly? The components for Word 97 /should/
>be compatible with later versions of Word.

>--
>Deborah Pate (TeamB) http://delphi-jedi.org

>  TeamB don't see posts sent via Google or ISPs
>  Use the real Borland server: newsgroups.borland.com
>  http://www.borland.com/newsgroups/genl_faqs.html

Re:Simple Word 97, 2000 and XP automation


<<Hedley Muscroft:
It's the WordDocument.ConnectTo line that fails on XP but works fine with
2000.

Quote

Hm. I can't reproduce this problem at all - you haven't got Norton Antivirus
installed, by any chance?

If it is a timing issue, you might resolve it by connecting Word and making
it visible before opening the document:

  WordApplication.Connect;
  WordApplication.Visible := true;
  FileName := IncludeTrailingBackslash(FDatabaseDir) + 'Docs\' + FileName;
  WordDocument.ConnectTo(WordApplication.Documents.Add(FileName,
EmptyParam));

--
Deborah Pate (TeamB) http://delphi-jedi.org

  TeamB don't see posts sent via Google or ISPs
  Use the real Borland server: newsgroups.borland.com
  http://www.borland.com/newsgroups/genl_faqs.html

Other Threads