Board index » delphi » Word 97 and Word 2000 Documents.Add method

Word 97 and Word 2000 Documents.Add method

Hi all

We have a program which needs to operate with both Word97 and Word 2000 as
it is used in many many sites. If we use the Word2000 and Office 2000 unit
it compiles fine but fails on Word97 with an exception.

Using the Word97/Office97 units to see which calls differ, we find the the
Documents.Add method has extra arguments in 2000. Mostly  we do not use
these arguments.

So is there a way we can allow both to work?

For example in Word2000 the call mught be:

  WordCom.Documents.Add(TemplateNameV,FalseV,EmptyParam,EmptyParam);

In Word97 there is

  WordCom.Documents.Add(TemplateNameV,False);

We want one program to invoke either one or the other depending on the
version, but we cannot get compilation with different number of parameters.

Similarly this applies to the Open command.

I'm probably missing something obvious but cannot see what it is (I do not
do a lot of COM programming in Delphi).

TIA
Paul

 

Re:Word 97 and Word 2000 Documents.Add method


Try
OleVariant(WordCom.Documents).Add(TemplateNameV,False);

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool

Quote
"Paul Redstone" <paul.redst...@solica.com> wrote in message

news:3e3ee1ae@newsgroups.borland.com...
Quote
> Hi all

> We have a program which needs to operate with both Word97 and Word 2000 as
> it is used in many many sites. If we use the Word2000 and Office 2000 unit
> it compiles fine but fails on Word97 with an exception.

> Using the Word97/Office97 units to see which calls differ, we find the the
> Documents.Add method has extra arguments in 2000. Mostly  we do not use
> these arguments.

> So is there a way we can allow both to work?

> For example in Word2000 the call mught be:

>   WordCom.Documents.Add(TemplateNameV,FalseV,EmptyParam,EmptyParam);

> In Word97 there is

>   WordCom.Documents.Add(TemplateNameV,False);

> We want one program to invoke either one or the other depending on the
> version, but we cannot get compilation with different number of
parameters.

> Similarly this applies to the Open command.

> I'm probably missing something obvious but cannot see what it is (I do not
> do a lot of COM programming in Delphi).

> TIA
> Paul

Re:Word 97 and Word 2000 Documents.Add method


<<Paul Redstone:
we find the the Documents.Add method has extra arguments in
2000. Mostly  we do not use these arguments.

Quote

If you don't use them at all you can simply use the AddOld
method for backwards compatibility. If you want to use them
sometimes, check the Application.Version property and call
Add or AddOld as appropriate.

--
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:Word 97 and Word 2000 Documents.Add method


In Word2000.pas I should run:
.Add method for Word2000 and Word2002?
.AddOld for Word 97?

Where do I find a nice overview of versions of Word?

Word97: 8
Word2000: 9
Word2002: 10?

I checked my own Word.version, and it returns (10.0). Is the second version
number in use?

Thanks.
Lars-H. Green
Norway

"Deborah Pate (TeamB)" <d.p...@blueyonder.co.not-this-bit.uk> wrote in
message news:VA.00001b2c.006eb8b3@blueyonder.co.not-this-bit.uk...

Quote
> <<Paul Redstone:
> we find the the Documents.Add method has extra arguments in
> 2000. Mostly  we do not use these arguments.

> If you don't use them at all you can simply use the AddOld
> method for backwards compatibility. If you want to use them
> sometimes, check the Application.Version property and call
> Add or AddOld as appropriate.

> --
> 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:Word 97 and Word 2000 Documents.Add method


<<Lars-Harald Green:
In Word2000.pas I should run:
.Add method for Word2000 and Word2002?
.AddOld for Word 97?

Quote

AddOld works with all three Word versions. The Word2000.Add
method has more parameters which allow you to say e.g
whether the document should be visible - but if you try
using that with Word97 it will crash.

<<Lars-Harald:
Where do I find a nice overview of versions of Word?

Quote

The Word VBA help files have a What's new section. You can
also look at the type library files to see what's changed,
remembering that with interfaces it's the order of methods
that matters, not the names, so any methods added to
interface in a new version will appear at the end of the
interface declaration.

<<Lars-Harald:
Word2002: 10?

Quote

Yes.

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