Board index » delphi » How to input parameters when use TWordApplication in Delphi 5?

How to input parameters when use TWordApplication in Delphi 5?

Hello everyone , please help me :
I want use Delphi 5 write a program , it can start Word and open a document.
I use a TWordApplication , name is WordApplication1 , I write :

/******
  WordApplication1.Connect;
  WordApplication1.Visible := true  ;
  WordApplication1.Documents.Open('c:\My Documents\readme.doc',
       msoTrue,msofalse,msofalse,'','',msotrue,nil,nil,msotrue);
*******/
But Compiler alway tell 'Types of actual and formal var parameters must be
identical'
why ? I try a lot of type , but error is as of old .

can you give some experience to use 'OleVariant' type ?

 

Re:How to input parameters when use TWordApplication in Delphi 5?


But finish this program in VB is very easy .

/*****
Dim a As Object
Set a = CreateObject("word.application")
a.Visible = True
a.Documents.Open FileName:="C:\My Documents\readme.doc"
******/
the parameters type in OLE invoke by Delphi is very troubled.
can you tell how to use OLE invoke by Delphi thank you .

I am proficienter in Delphi then in VB.

Quote
adamdog <adam...@163.net> wrote in message

news:8g28v5$68r1@bornews.borland.com...
Quote
> Hello everyone , please help me :
> I want use Delphi 5 write a program , it can start Word and open a
document.
> I use a TWordApplication , name is WordApplication1 , I write :

> /******
>   WordApplication1.Connect;
>   WordApplication1.Visible := true  ;
>   WordApplication1.Documents.Open('c:\My Documents\readme.doc',
>        msoTrue,msofalse,msofalse,'','',msotrue,nil,nil,msotrue);
> *******/

> But Compiler alway tell 'Types of actual and formal var parameters must be
> identical'
> why ? I try a lot of type , but error is as of old .

> can you give some experience to use 'OleVariant' type ?

Re:How to input parameters when use TWordApplication in Delphi 5?


<<Adamdog:
'Types of actual and formal var parameters must be
identical'

Quote

That just mean you have to use a variable as the
parameter. E.g.
var
  OleTrue: olevariant;
...
  OleTrue := True;
  Word.SomeFunction(OleTrue);

In this case I think you should also know about the
EmptyParam variant which you can use when you
just want the default parameter. You might find
my web site helpful:
http://www.djpate.freeserve.co.uk/Automation.htm

--
Deborah Pate

Re:How to input parameters when use TWordApplication in Delphi 5?


I'm just starting to investigate whether I can control Word and/or
WordPerfect from D5. I went to your web site. It seems that I can do a lot
with automation of Word. What can you tell me about WordPerfect?

Thanks,

Keith Marbach

Quote
"Deborah Pate" <d.p...@cableinet.co.not-this-bit.uk> wrote in message

news:3924e4f2@dnews...
Quote
> <<Adamdog:
> 'Types of actual and formal var parameters must be
> identical'

> That just mean you have to use a variable as the
> parameter. E.g.
> var
>   OleTrue: olevariant;
> ...
>   OleTrue := True;
>   Word.SomeFunction(OleTrue);

> In this case I think you should also know about the
> EmptyParam variant which you can use when you
> just want the default parameter. You might find
> my web site helpful:
> http://www.djpate.freeserve.co.uk/Automation.htm

> --
> Deborah Pate

Other Threads