OLE with Excel.
-
- Posts: 388
- Joined: Sun Nov 06, 2005 3:55 pm
- Location: Southern California, USA
- Contact:
OLE with Excel.
I find many problems with using OLE with Excel. I believe it is because Excel is running in the background when I attempt to launch a new instance. I attempted to use IsExeRunning("Excel",".",.f.) including many versions with case "EXCEL", and "excel" and it seems it reports accurately on the first call, but incorrectly for every call after. Is there a better way to detect if an executable is running on a workstation?
Thanks,
Thanks,
Thanks,
Byron Hopp
Matrix Computer Services
Byron Hopp
Matrix Computer Services
- Enrico Maria Giordano
- Posts: 8767
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Has thanked: 1 time
- Been thanked: 5 times
- Contact:
Re: OLE with Excel.
Can you prepare a little sample showing the problem that can be compiled and run?
-
- Posts: 388
- Joined: Sun Nov 06, 2005 3:55 pm
- Location: Southern California, USA
- Contact:
Re: OLE with Excel.
Just pop this into any app that has a menu so you can call it multiple times without terminating the app.
Function McsExcelRunning()
If IsExeRunning( "excel",".",.F. )
MsgStop( "Excel is currently running...","IsExeRunning" )
Else
MsgInfo( "Excel is not running...","IsExeRunning" )
Endif
Return nil
Function McsExcelRunning()
If IsExeRunning( "excel",".",.F. )
MsgStop( "Excel is currently running...","IsExeRunning" )
Else
MsgInfo( "Excel is not running...","IsExeRunning" )
Endif
Return nil
Thanks,
Byron Hopp
Matrix Computer Services
Byron Hopp
Matrix Computer Services
- Enrico Maria Giordano
- Posts: 8767
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Has thanked: 1 time
- Been thanked: 5 times
- Contact:
Re: OLE with Excel.
This is a working sample:
Code: Select all | Expand
#include "Fivewin.ch"
FUNCTION MAIN()
? EXELRUNNING()
? EXELRUNNING()
RETURN NIL
STATIC FUNCTION EXELRUNNING()
LOCAL lRun := .F.
TRY
GETACTIVEOBJECT( "Excel.Application" )
lRun = .T.
CATCH
END
RETURN lRun
-
- Posts: 388
- Joined: Sun Nov 06, 2005 3:55 pm
- Location: Southern California, USA
- Contact:
-
- Posts: 388
- Joined: Sun Nov 06, 2005 3:55 pm
- Location: Southern California, USA
- Contact:
Re: OLE with Excel.
hi Byron,
how do you "close" OLE Connection to Excel ?
byron.hopp wrote:I believe it is because Excel is running in the background when I attempt to launch a new instance.
how do you "close" OLE Connection to Excel ?
Code: Select all | Expand
// Start Excel
oExcel := CreateObject( "Excel.Application" )
...
// Quit Excel
oExcel:Quit()
// destroy the reference
oExcel:destroy()
oExcel := NIL
IF ComLastError() > 0
greeting,
Jimmy
Jimmy
- Enrico Maria Giordano
- Posts: 8767
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Has thanked: 1 time
- Been thanked: 5 times
- Contact:
Re: OLE with Excel.
hi,
i´m not sure how under FiveWin but it is recommend to o:Destroy() -> o:End() an ActiveX "Connection" and NIL it
o:Quit() is like close Firefox but still have Internet "Connection"
i´m not sure how under FiveWin but it is recommend to o:Destroy() -> o:End() an ActiveX "Connection" and NIL it
o:Quit() is like close Firefox but still have Internet "Connection"
greeting,
Jimmy
Jimmy
- nageswaragunupudi
- Posts: 10729
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 10 times
- Contact:
Re: OLE with Excel.
byron.hopp wrote:I find many problems with using OLE with Excel. I believe it is because Excel is running in the background when I attempt to launch a new instance. I attempted to use IsExeRunning("Excel",".",.f.) including many versions with case "EXCEL", and "excel" and it seems it reports accurately on the first call, but incorrectly for every call after. Is there a better way to detect if an executable is running on a workstation?
Thanks,
Please use
Code: Select all | Expand
oExcel := ExcelObj()
ExcelObj() is a FWH function which takes care of whether Excel is already running.
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- Enrico Maria Giordano
- Posts: 8767
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Has thanked: 1 time
- Been thanked: 5 times
- Contact:
Re: OLE with Excel.
Jimmy wrote:hi,
i´m not sure how under FiveWin but it is recommend to o:Destroy() -> o:End() an ActiveX "Connection" and NIL it
o:Quit() is like close Firefox but still have Internet "Connection"
No, it is not. Quit() method is enough to ensure your instance of Excel is completely removed from memory. Just check it with Task Manager.