0

I have a problem since the update of Excel 2016 in version 1712.

If we do a "application.quit" in a macro and don't use the Excel GUI, Excel seems to be closed but the process is still alive.

If we call the macro with a button or an action in excel it works and in debug, step by step, it works fine.
But if we call the macro on workbook opening it won't.

A simple example : An empty Workbook with only one macro

Private Sub Workbook_Open()
    Application.Quit
End Sub

I tried "wait","doevents","screenupadating",change visibility.

It happen on several computers.

Has anyone experienced this as well?

braX
  • 11,506
  • 5
  • 20
  • 33
  • 2
    What would be the point of closing a workbook as soon as you've opened it? – Herco Feb 09 '18 at 08:54
  • Possible duplicate https://stackoverflow.com/questions/21291083/vba-automation-of-excel-leaves-a-process-in-memory-after-quit – TomJohn Feb 09 '18 at 09:30
  • I agree with @Herco that there is really no point of executing the `Quit` method on open. You usually put it in `Workbook_BeforeClose` event. – L42 Feb 09 '18 at 09:55
  • Obviously there is no point to do that, it's just an example. The point is to do many things before quit (import data, modify them, saveas ...) – Benjamin F Feb 09 '18 at 10:29

1 Answers1

1

try to execute a kill command to kill excel

Something like this:

Taskkill /IM Excel.exe /F

I suppose you know how to execute command within vbscript. In case you do not know:

Dim objShell
Set objShell = WScript.CreateObject ("WScript.shell")
objShell.run "cmd /c 'Taskkill /IM Excel.exe /F'"
Set objShell = Nothing
Vincent Zhang
  • 369
  • 3
  • 11
  • Of course it works and i already made something like this temporarily but it's a dirty solution. I want Excel to close himself properly not to suicide. – Benjamin F Feb 09 '18 at 10:34