FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Disable Excel from running
Posts: 512
Joined: Mon Oct 17, 2005 10:38 AM
Disable Excel from running
Posted: Wed Feb 13, 2019 06:54 PM

Hi to all.
I have a problem with a procedure that create a big Excel file, with several sheets and a lot of lines.
Everything works fine except that sometimes an employee while is waiting opens another Excel file.
At that time the window opens the file that is creating in memory. And if he closes che windows the
procedure stops with the usual ole error.
Is there a way to block Excel from executing if is already running in memory ?
Or to intercept the errors inside the program like in VBA with the "On Error" statement ?
Thanks a lot.
Massimo

Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: Disable Excel from running
Posted: Thu Feb 14, 2019 03:11 AM
Just an idea. Can't you just make the procedure initiate new instance of Excel everytime?

I mean instead of
Code (fw): Select all Collapse
TRY
    oExcel := GetActiveObject( "Excel.Application" )
CATCH
    TRY
        oExcel := CreateObject( "Excel.Application" )
    END
END


Just use oExcel := CreateObject( "Excel.Application" ) everytime. That way what the opening and closing of excel by the employee shouldn't affect your program because he's running a different instance of excel.
FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 512
Joined: Mon Oct 17, 2005 10:38 AM
Re: Disable Excel from running
Posted: Thu Feb 14, 2019 07:11 PM

Hi.
This is a good idea. I must make some tests.
Thanks a lot.
Massimo

Continue the discussion