![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Feb 2002
Location: ]-[ /-\ \/\/ /-\ | | ~~~@|_()]-[/-\!!!
Posts: 48
|
I have an Excel workbook (that has worked normally) that kept crashing on me, closing the program. I figured out the problem: there was a running instance of Excel in the background which was causing this particular workbook to get a housecall from Dr Watson(checked task manager/processes tab and tested theory). I would like to add some vba code to the workbook_open event of this workbook to check if there is a running instance of Excel and to terminate it to prevent this "bug" from coming back. There is a way I have seen, but I don't recall how it's done. Can anyone help me? Much Mahalo!
Aloha! *(Excel2k/WinNT4 sp6) |
|
|
|
|
|
#2 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Portland, OR USA
Posts: 1,374
|
Quote:
Dim xl as New Excel.Application ' or Dim xl as Excel.Application Set xl = New Excel.Application then that is most likely where your problem lies. You should either use GetObject or make sure that you close the New instance of Excel when the program is finished: xl.Quit Set xl = Nothing Hope this helps, Russell [ This Message was edited by: Russell Hauf on 2002-02-27 13:12 ] |
|
|
|
|
|
|
#3 |
|
New Member
Join Date: Feb 2002
Location: ]-[ /-\ \/\/ /-\ | | ~~~@|_()]-[/-\!!!
Posts: 48
|
Russell,
Don't know if there is another app out there that is launching instance of Excel or not (at least I didn't write any vba to do this). I do have application.quit in thisworkbook object (beforeclose) so that excel closes when the workbook is closed (it's like an "app"). Other than that, I think I will not have an easy time finding out a fix for this(!) Mahalo much anyway! Aloha! |
|
|
|
|
|
#4 | |
|
Board Regular
Join Date: Mar 2002
Location: Hilo, Hawaii
Posts: 240
|
Quote:
when run it will find any instance of xl that is currently active even if hidden. I keep mine on the desktop so I dont have to go looking for it. Dim objXL Dim strMessage On Error Resume Next ' Try to grab a running instance of ' Excel... Set objXL = GetObject(, "Excel.Application") ' What did we find?.. If Not TypeName(objXL) = "Empty" Then strMessage = "Excel Running." Else strMessage = "Excel Not Running." End If ' Feedback to user... MsgBox strMessage, vbInformation, "Excel Status" ' Make the Excel instance visible ' if we found one if strMessage = "Excel Running." then _ objXL.Visible = true PS Moving to the Big Island in two years see you there. Visiting for a month this November!! Aloha [ This Message was edited by: KniteMare on 2002-03-05 13:34 ] [ This Message was edited by: KniteMare on 2002-03-05 13:40 ] |
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|