Board index » delphi » Excel Ole Automation

Excel Ole Automation


2006-10-26 10:41:08 PM
delphi176
Delphi 7 -
I have an app with this code in the frmMain.Activate event.
try
ExcelApp := GetActiveOleObject('Excel.Application');
except
try
// If no instance of Word is running, try to Create a new Excel Object
ExcelApp := CreateOleObject('Excel.Application');
except
ShowMessage('Cannot start Excel/Excel not installed ?');
Exit;
end
end;
When I run the program in the IDE, I get an exception which says:
" ... exception EOleSysErr with message "Operation Unavilable" ... "
However, when I compile it and run the EXE from the command line, I have
no problem. Why will it not run from the IDE? Is there a setting I need
to change?
Thanks,
Bob
 
 

Re:Excel Ole Automation

I think having that code in the OnActivate event is
maybe part of your problem here - try moving it to
the OnShow instead and see if it gets fixed.
 

Re:Excel Ole Automation

"BobW" <XXXX@XXXXX.COM>wrote in
Quote

Delphi 7 -

I have an app with this code in the frmMain.Activate event.

try
ExcelApp := GetActiveOleObject('Excel.Application');
If the line above generates an exception it will, by default, be caught by
the IDE before being caught by your except clause. To disable this, go to
Tools | De{*word*81} options | Language exceptions and uncheck the Stop on
Delphi exceptions checkbox in the bottom left-hand corner of the main
panel.
Quote
except
...
--
For e-mail address, remove the XXs
 

Re:Excel Ole Automation

Thank you - that worked fine.
Bob
____________________
"Chris Cheney" <XXXX@XXXXX.COM>writes
Quote
"BobW" <XXXX@XXXXX.COM>wrote in
news:4540c902$XXXX@XXXXX.COM:

>
>Delphi 7 -
>
>I have an app with this code in the frmMain.Activate event.
>
>try
>ExcelApp := GetActiveOleObject('Excel.Application');

If the line above generates an exception it will, by default, be caught by
the IDE before being caught by your except clause. To disable this, go to
Tools | De{*word*81} options | Language exceptions and uncheck the Stop on
Delphi exceptions checkbox in the bottom left-hand corner of the main
panel.

>except
>...

--
For e-mail address, remove the XXs