Board index » delphi » OLE Newbie: Controlling an OLE object from a Delphi 1 app

OLE Newbie: Controlling an OLE object from a Delphi 1 app

I have a Delphi 1 (16-bit) application that needs to interface with an OLE
server object.  This OLE object has some functions I need to call.  I can
get my Delphi app to instantiate the OLE object and get it running by using
the TOleContainer object on the palette.  But I cannot control the OLE
object from my app (which I need to do).  I'm down to researching the
Windows OLE API functions to try to achieve this (which is a big pain) -
surely there must be an easier way using a VCL component.  Have I just
missed something obvious?

Has anyone written a Delphi app that controls an OLE server object?  For
example, started up WINWORD from within the app and then issued a few
WordBasic commands (from within the app).  Maybe there's a 3rd-party
component which encapsulates more OLE functionality than the TOleContainer
- specifically the ability to invoke functions in the OLE object (server)
from within OLE container (client).

Any suggestions at all would be appreciated.

--
+----------------------+--------------------------------+
|    Mike Hodgson      |  Email: mi...@handson.com.au   |
| Analyst/Programmer   |  Ph:    + 61 2 9906 2400       |
|  Hands-On Systems    |  Fax:   + 61 2 9906 4431       |
+----------------------+--------------------------------+
'Join the Army, travel the world, meet interesting people, and kill them.'

 

Re:OLE Newbie: Controlling an OLE object from a Delphi 1 app


Quote
Mike Hodgson wrote:

> I have a Delphi 1 (16-bit) application that needs to interface with an OLE
> server object.  This OLE object has some functions I need to call.  I can
> get my Delphi app to instantiate the OLE object and get it running by using
> the TOleContainer object on the palette.  But I cannot control the OLE
> object from my app (which I need to do).  I'm down to researching the
> Windows OLE API functions to try to achieve this (which is a big pain) -
> surely there must be an easier way using a VCL component.  Have I just
> missed something obvious?

> Has anyone written a Delphi app that controls an OLE server object?  For
> example, started up WINWORD from within the app and then issued a few
> WordBasic commands (from within the app).  Maybe there's a 3rd-party
> component which encapsulates more OLE functionality than the TOleContainer
> - specifically the ability to invoke functions in the OLE object (server)
> from within OLE container (client).

Here's an example of OLE and Excel..

procedure TCard.PrintCards(IRpt : TIRpt);
var  
   ExcelApp : Variant;
begin
   Application.ProcessMessages;
   ExcelApp:= CreateOleObject('Excel.Application');
   ExcelApp.Visible := False;
   try
      ExcelApp.WorkBooks.Open('C:\Cards\Card.xls');
      ExcelApp.WorkSheets('Cards').Activate;
      ExcelApp.Range('J3').Value := IntToStr(m_nDGNumber);
      ExcelApp.Range('A5').Value := ABTSSIRpt.DGroupName;
      ExcelApp.Range('A5').Font .Bold := True;
      ExcelApp.Range('I3').Value:='Group Id:';
      ExcelApp.Range('I3').Font .Bold := True;

   finally
      ExcelApp.ActiveWorkbook.Close(SaveChanges:=False);
      ExcelApp.Quit;
   end;
end;

Hope that helps!

Rkr

--
                   \|||/
                   /'^'\
                  ( 0 0 )
--------------oOOO--(_)--OOOo--------------
. Reid Roman                              .
. Delphi Programmer / Analyst             .
. TVisualBasic:=class(None);              .
. May the Source be With You              .
-------------------------------------------
. Auto-By-Tel (http://www.autobytel.com)  .
. Irvine, CA U.S.A                        .
. E-Mail : rkroman (at) pacbell (dot) net .
. or reidr (at) autobytel (dot) com       .
-------------------------------------------

Re:OLE Newbie: Controlling an OLE object from a Delphi 1 app


Reid...

The first reply will only work in Delphi 2 or above (which you are not
using).
There is a 3rd party component called TOLEAutomation which is for D1, and
fits your needs perfectly (I didn't write it and have no connections with
the people who did, do this is not a plug !).

Cheers Rich.......

Quote
Reid Roman wrote in message <35925544.5CEBA...@pacbell.net>...
>Mike Hodgson wrote:

>> I have a Delphi 1 (16-bit) application that needs to interface with an
OLE
>> server object.  This OLE object has some functions I need to call.  I can
>> get my Delphi app to instantiate the OLE object and get it running by
using
>> the TOleContainer object on the palette.  But I cannot control the OLE
>> object from my app (which I need to do).  I'm down to researching the
>> Windows OLE API functions to try to achieve this (which is a big pain) -
>> surely there must be an easier way using a VCL component.  Have I just
>> missed something obvious?

>> Has anyone written a Delphi app that controls an OLE server object?  For
>> example, started up WINWORD from within the app and then issued a few
>> WordBasic commands (from within the app).  Maybe there's a 3rd-party
>> component which encapsulates more OLE functionality than the
TOleContainer
>> - specifically the ability to invoke functions in the OLE object (server)
>> from within OLE container (client).

>Here's an example of OLE and Excel..

>procedure TCard.PrintCards(IRpt : TIRpt);
>var
>   ExcelApp : Variant;
>begin
>   Application.ProcessMessages;
>   ExcelApp:= CreateOleObject('Excel.Application');
>   ExcelApp.Visible := False;
>   try
>      ExcelApp.WorkBooks.Open('C:\Cards\Card.xls');
>      ExcelApp.WorkSheets('Cards').Activate;
>      ExcelApp.Range('J3').Value := IntToStr(m_nDGNumber);
>      ExcelApp.Range('A5').Value := ABTSSIRpt.DGroupName;
>      ExcelApp.Range('A5').Font .Bold := True;
>      ExcelApp.Range('I3').Value:='Group Id:';
>      ExcelApp.Range('I3').Font .Bold := True;

>   finally
>      ExcelApp.ActiveWorkbook.Close(SaveChanges:=False);
>      ExcelApp.Quit;
>   end;
>end;

>Hope that helps!

>Rkr

>--
>                   \|||/
>                   /'^'\
>                  ( 0 0 )
>--------------oOOO--(_)--OOOo--------------
>. Reid Roman           .
>. Delphi Programmer / Analyst           .
>. TVisualBasic:=class(None);           .
>. May the Source be With You   .
>-------------------------------------------
>. Auto-By-Tel (http://www.autobytel.com)  .
>. Irvine, CA U.S.A   .
>. E-Mail : rkroman (at) pacbell (dot) net .
>. or reidr (at) autobytel (dot) com   .
>-------------------------------------------

Re:OLE Newbie: Controlling an OLE object from a Delphi 1 app


Quote
On Fri, 26 Jun 1998 12:15:53 +0100, <n...@landy.clara.net> wrote:
>Reid...

>The first reply will only work in Delphi 2 or above (which you are not
>using).
>There is a 3rd party component called TOLEAutomation which is for D1, and
>fits your needs perfectly (I didn't write it and have no connections with
>the people who did, do this is not a plug !).

>Cheers Rich.......

I have used that component and I'm quite satisfied with it. Here is
some information of the prices and addresses:

                                ORDER FORM

        Send your order to:

                E-mail:  tolea...@swdev.co.nz
                                (previously: sra...@iconz.co.nz)
         or CompuServe:  100236,1656

                   FAX:  64-9-832-0088   (New Zealand)

                  Mail:  Software Developer (Raike)
                         66 Simpson Rd.
                         Swanson
                         Auckland 8, NEW ZEALAND

------------------------------------------------------------------
        Please rush me ____ copies of TOleAutoClient V1.1 for Delphi
        at US$39.95 each.
        OR, please upgrade my ____ copies of V1.0 at US$19.95 each.
        Indicate here ____ for E-mail delivery (US$2.00).

Mechaul Oy - Ohjelmistotuotteet
Janne Timmerbacka
Easy Contact - tuotep??llikk?

gsm     040-5525448
email   easycont...@mechaul.com
www     http://www.mechaul.com/ohjelmat/

Tehdaskyl?nkatu 7                      
11711 RIIHIM?KI
vaihde 019-733446

Other Threads