Re: How to late-bind Excel

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



1) Delphi can use Excel as a server with early binding (binding Excel's
type library),
but this adds about 350 kb to its code: i don't like it.

2) My DLL is, mostly, a library of functions that are called from VBA.
However, having
the right reference, the DLL can interact with and/or transfer data to
Excel directly.
Further, it would be nice to move part of the code from VBA to the DLL
(maybe
not faster, but at least to protect the code).

3) For Delphi, the reference to Excel is simply a variant (to be
precise an OleVariant,
i.e. a variant compatible with ole types). You create it, for example,
with the usual

xlapp := GetObject ('Excel.Application');

(well, in Delphi the method is called GetActiveOleObject )

4) Delphi knows how to treat xlapp as a IDispatch interface, so it
accepts a
statement like

xlapp.Caption := 'My application';

which is identical to a vba statement.

The whole point was only related to the inconvenience of the GetObject
method:
assuming we have multiple copies of Excel running at the same time, how
do you make yourself sure that you're are linking your dll to the RIGHT
instance ?

My idea was to pass to the dll (in an initialization step) the object
Excel.Application:
after all this should be passed somehow as an address, from which it
should be
possible to recover the right value to initialize the xlapp variable in
Delphi.

Hope this makes a little bit more clear the original post and its
purpose.

.



Relevant Pages

  • Re: Delphi reflection etc
    ... >> The delphi groups here in particular, ... > Well, as another data point, I do get a higher response rate on the MS ... It's at least possible that my Delphi questions run ... using late binding for Excel with .NET and accessing array properties. ...
    (borland.public.delphi.non-technical)
  • Re: Viewing Excel Files
    ... our ExcelFile Viewer wriiten in Delphi using ... You may load your xls-file and view in your Delphi application ... These will allow me to create the excel files. ...
    (borland.public.delphi.thirdpartytools.general)
  • Re: DLL and Excel2000
    ... > have come to believe that password protection in Excel and VBA is a joke. ... > have but I am not sure it will result in one simple executible or DLL, ... > also feel Delphi code is more concise, ...
    (comp.lang.pascal.delphi.misc)
  • DLL and Excel2000
    ... I have a program for a special need in Excel and VBA. ... also feel Delphi code is more concise, ...
    (comp.lang.pascal.delphi.misc)
  • Re: Excel automation late binding
    ... The approach I've found most useful is to create a separate DLL and have the ... DLL using early binding to Excel, and your app can be early-bound to the ... How about checking for Excel during the setup and then change ...
    (microsoft.public.vb.general.discussion)