Board index » delphi » Check existence of Excel?

Check existence of Excel?

Hi!

I'm using Delphi 3 and I want to use Excel by OLE automation. How can I
check the existence / version of Excel?

TIA

Marc

 

Re:Check existence of Excel?


In article <MPG.10d337bd18433445989...@forums.inprise.com>, M. Schneider
wrote:
Quote
> I'm using Delphi 3 and I want to use Excel by OLE automation. How can I
> check the existence / version of Excel?

Try this:
---cut here---
uses
  ActiveX;

procedure TForm1.Button1Click(Sender: TObject);
var
  clsID: TGuid;
  w: WideString;
begin
  w := Edit1.Text;
  ClsIDFromProgID(PWideChar(w), clsID);
  if IsEqualGuid(clsid, guid_null) then
    ShowMessage(w+' is available')
  else
    ShowMessage(w+' is NOT available');
end;
---cut here---

This will, in all likelihood, show you what progids are available (e.g.,
put Excel.Application.8 in Edit1.  HOWEVER, it's possible that the user
will delete the Excel EXE while the registry will still show the progID as
available.  Summary:  This code will work fine on most systems, but you
will only be 100% sure of the existence of the server when you actually
call CreateOleObject() (which will throw an EOleSysError if there's a
problem).

--
Sat, 05 Dec 1998 15:56 EST
Jim O'Brien, UnitOOPS Software
unito...@remove-this-prefix.unitoops.com
Check out our OLE Drag and Drop Components at http://www.unitoops.com/

Re:Check existence of Excel?


Quote
In article <VA.00000107.2736f9a8@quantify>, Jim O'Brien wrote:
> if IsEqualGuid(clsid, guid_null) then

Oops...that should be

if NOT IsEqualGuid...

<blush>

--
Sun, 06 Dec 1998 14:52 EST
Jim O'Brien, UnitOOPS Software  
unito...@remove-this-prefix.unitoops.com
Check out our OLE Drag and Drop Components at
<http://www.unitoops.com/>
Browse examples online at <http://www.unitoops.com/uoole/examples/>

Re:Check existence of Excel?


Quote
>I'm using Delphi 3 and I want to use Excel by OLE automation. How can I
>check the existence / version of Excel?

As an idea, don't use COM/OLE/Registry to check this!

Use FindFirst/FindNext/FindClose to look for excel.exe (if you want Excel
97....this may be msexcel.exe in previous version...check for the file you
want) then use GetVersionInfoSize and GetVersionInfo to check for the
appropriate version.

AJ

Re:Check existence of Excel?


Quote
In article <74g5kj$7...@forums.borland.com>, Andy Jeffries wrote:
> As an idea, don't use COM/OLE/Registry to check this!

Your point is well taken, but just because the EXE exists is no guarantee that
the OLE setup hasn't been broken.  A combination is probably best...

--
Mon, 07 Dec 1998 15:06 EST
Jim O'Brien, UnitOOPS Software   unito...@remove-this-prefix.unitoops.com
Check out our OLE Drag and Drop Components at <http://www.unitoops.com/>
Browse examples online at <http://www.unitoops.com/uoole/examples/>

Re:Check existence of Excel?


Quote
>Your point is well taken, but just because the EXE exists is no guarantee
that
>the OLE setup hasn't been broken.  A combination is probably best...

I agree... a combination is best.  We both approached the problem from
different sides (and both ignored the other side).

Good plan, check the OLE setup is there and the EXE is there!!!

Andy Jeffries

Other Threads