Page 1 of 1

Disable Excel from running

PostPosted: Wed Feb 13, 2019 6:54 pm
by Massimo Linossi
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

Re: Disable Excel from running

PostPosted: Thu Feb 14, 2019 3:11 am
by hua
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.

Re: Disable Excel from running

PostPosted: Thu Feb 14, 2019 7:11 pm
by Massimo Linossi
Hi.
This is a good idea. I must make some tests.
Thanks a lot.
Massimo