Board index » delphi » TOleConteiner error 'Interface not supported'

TOleConteiner error 'Interface not supported'

Hi,

I want to use OleObject property of TOleContainer to change a MSWord
document by the program, but get the error message 'Interface not
supported',

  OleContainer1.CreateObjectFromFile('C:\Work\MSWordAutomation\test.doc',
false);
  OleContainer1.OleObject.ActiveDocument.Range.Text := 'Ole object testing
string...';  ///error message

What do I wrong?

Regards,
Nenad.

 

Re:TOleConteiner error 'Interface not supported'


<<Nebl:
'Interface not supported',

Quote

You have to active the object in the olecontainer before
you can give it commands. And the object in the
olecontainer /is/ the active document, not the Word
application. So:

  OleContainer1.Run;
  { or OleContainer1.Doverb(ovShow); }

  OleContainer1.OleObject.Range.Text :=
                'Ole object testing string...'

--
Deborah Pate (TeamB)
http://delphi-jedi.org
Sorry, no email please.

Re:TOleConteiner error 'Interface not supported'


Thanks Deborah,

now i can access the document and even the application becuse i need the
selection object in the following way:

CreateObjectFromFile(FFileName, false);
doVerb(ovShow);
MSWord := OleObject;
MSWord:= MSWord.Application;
MSWord.ActiveDocument.Range.InsertAfter('Ole object testing ...');
I have to bother you with one more cuestion: It will be nice if the Delphi
code insight worked like with delphi objects, do you know an aprouch to make
the objects 'visible' for the Delphi code insight?

Regards,
Nenad.

"Deborah Pate (TeamB)" <d.p...@cableinet.co.not-this-bit.uk> wrote in
message news:VA.0000058f.006a209a@cableinet.co.not-this-bit.uk...

Quote
> <<Nebl:
> 'Interface not supported',

> You have to active the object in the olecontainer before
> you can give it commands. And the object in the
> olecontainer /is/ the active document, not the Word
> application. So:

>   OleContainer1.Run;
>   { or OleContainer1.Doverb(ovShow); }

>   OleContainer1.OleObject.Range.Text :=
>                 'Ole object testing string...'

> --
> Deborah Pate (TeamB)
> http://delphi-jedi.org
> Sorry, no email please.

Re:TOleConteiner error 'Interface not supported'


<<Nebl:
do you know an aprouch to make the objects 'visible' for
the Delphi code insight?

Quote

Yes, all you have to do is use the type library files. If
you have D5, then put either Word97 or Word2000 in your
uses clause - with earlier versions of Delphi you'll need
to import the Word type library and put Word_TLB in your
uses clause. Then you just pop the interfaces out of the
OleObject, like this:

var
  Doc: _Document;
  Word: _Application;
..
  Doc := IDispatch(OleContainer1.OleObject) as _Document;
  Word := Doc.Application;

and then when you type code like this, you'll get help from
code insight:

  Word.Selection.TypeText('Rise like lions after slumber');
  Doc.Range(EmptyParam, EmptyParam).InsertAfter(
                          'In unvanquishable number ');

As those Emptyparams show, though, you'll have to obey the
restrictions of early binding as well, and supply
EmptyParam arguments for every optional parameter.

--
Deborah Pate (TeamB)
http://delphi-jedi.org
Sorry, no email please.

Other Threads