Disable Excel from running

Disable Excel from running

Postby Massimo Linossi » Wed Feb 13, 2019 6: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
User avatar
Massimo Linossi
 
Posts: 498
Joined: Mon Oct 17, 2005 10:38 am
Location: Italy

Re: Disable Excel from running

Postby hua » Thu Feb 14, 2019 3:11 am

Just an idea. Can't you just make the procedure initiate new instance of Excel everytime?

I mean instead of
Code: Select all  Expand view

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
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am

Re: Disable Excel from running

Postby Massimo Linossi » Thu Feb 14, 2019 7:11 pm

Hi.
This is a good idea. I must make some tests.
Thanks a lot.
Massimo
User avatar
Massimo Linossi
 
Posts: 498
Joined: Mon Oct 17, 2005 10:38 am
Location: Italy


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Marc Venken, Silvio.Falconi and 100 guests