P
Paul Clement
¤ Paul,
¤
¤ I tried to dispose of Range and s but to no avail even if I do it in the
¤ loop itself so that they are disposed of before they are re-assigned... This
¤ is driving me nuts.
¤
¤ Atchoum
¤
Well if all else fails you can always use API function calls to kill the process:
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal
lpWindowName As String) As Int32
Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Int32, ByVal wMsg
As Int32, ByVal wParam As Int32, ByVal lParam As Int32) As Int32
Public Function TerminateExcel()
Dim ClassName As String
Dim WindowHandle As Int32
Dim ReturnVal As Int32
Const WM_QUIT = &H12
Do
ClassName = "XLMain"
WindowHandle = FindWindow(ClassName, Nothing)
If WindowHandle Then
ReturnVal = PostMessage(WindowHandle, WM_QUIT, 0, 0)
End If
Loop Until WindowHandle = 0
End Function
Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
¤
¤ I tried to dispose of Range and s but to no avail even if I do it in the
¤ loop itself so that they are disposed of before they are re-assigned... This
¤ is driving me nuts.
¤
¤ Atchoum
¤
Well if all else fails you can always use API function calls to kill the process:
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal
lpWindowName As String) As Int32
Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Int32, ByVal wMsg
As Int32, ByVal wParam As Int32, ByVal lParam As Int32) As Int32
Public Function TerminateExcel()
Dim ClassName As String
Dim WindowHandle As Int32
Dim ReturnVal As Int32
Const WM_QUIT = &H12
Do
ClassName = "XLMain"
WindowHandle = FindWindow(ClassName, Nothing)
If WindowHandle Then
ReturnVal = PostMessage(WindowHandle, WM_QUIT, 0, 0)
End If
Loop Until WindowHandle = 0
End Function
Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)