03-28-2003, 03:01 PM
I use the following code for open Microsoft Excel and add workbook.
I want to check if Microsoft Excel has closed after opening with the following code.
Dim xl As Object
Set xl = CreateObject("Excel.Application")
xl.Visible = True
03-28-2003, 06:05 PM
It won't close until you close it:
Set xl = Nothing
It's a good idea to put this in your exit routine that runs after an error, also:
On Error Resume Next
Set xl = Nothing
03-29-2003, 03:55 AM
I use Set xl = Nothing but i want to check if the Microsoft Excel program has close from the user (click x button and close Excel program).
Thanks for your attempt to help me.
03-31-2003, 09:46 AM
What about this:
Function ExcelRunning() As Boolean
On Error GoTo errXLRunning
Dim objXL As Excel.Application
Set objXL = GetObject(, "Excel.Application")
ExcelRunning = True
Set objXL = Nothing
If Err = 429 Then ExcelRunning = False: Exit Function
MsgBox "Error #" & Err & ": " & Err.Description
03-31-2003, 01:46 PM
I know this way but I want to check only the Excel was open with my VBA code. If I open the Excel with Start-> Programs-> Microsoft Excel (from windows) and later open again Excel with my VBA code (2 Excel is open) and later close only Excel that open with VBA code and later run your code then exist problem.
Thanks for your attempt to help me :)
03-31-2003, 02:05 PM
Is this something you need for debugging purposes or as a part of an application? Specifically, what is the error or problem you're having that makes you want to check if a VBA-instantiated instance of Excel is still running, after you have already used the Application.Quit method and set the variable to nothing? I've always just figured if I shut down the automated application in my code, set the variable to Nothing, and do the same in my error routine, it's covered. Just curious what's actually happening to your app...?