0

I am calling Excel objects from MS Access and I do not manage to close the instance!

One would believe that the workbooks are closed because we cannot see them anymore but in task Manager --> Processes I still have EXCEL.EXE*32 running...

This is what I have:

Dim xlApp as Excel.Application
Dim wbks as Workbooks


    Set xlApp = GetObject("", "Excel.Application")
    Set wbks = xlApp.Workbooks
    wbks.Open "C:\blp\api\Office Tools\BloombergUI.xla"
    wbks("BloombergUI.xla").RunAutoMacros (xlAutoOpen)

    wbks.Add
    xlApp.Visible = True

...performs actions...

xlApp.Workbooks(1).SaveAs FileName:=strFullPath, FileFormat:=xlCSV

    xlApp.Application.DisplayAlerts = False
    xlApp.Workbooks("BbgDivData.csv").Close SaveChanges:=True
    wbks("BloombergUI.xla").Close

    xlApp.Quit
    Set xlApp = Nothing

Any idea why it is still there? I suspect the Add-in to mess things up!

Erik A
  • 31,639
  • 12
  • 42
  • 67
ProtoVB
  • 773
  • 5
  • 12
  • 24
  • is wbks.Add maybe creating a second Excel instance? Try explicitly creating a new Excel object and making a new workbook in it for your actions, then call .quit on both. – Alan Waage Dec 04 '13 at 20:42
  • I'm inclined to go with your suspicions, though it might be worth steppign through your code in debug and looking at what happens in task manager re excel instances at each step. – John Bingham Dec 06 '13 at 03:54
  • possible duplicate of [Remove Excel task from Task manager after running from Access using VBA](http://stackoverflow.com/questions/22512868/remove-excel-task-from-task-manager-after-running-from-access-using-vba) – RubberDuck Dec 28 '14 at 22:33

1 Answers1

1

You never explicitly set the collection of workbooks to nothing, you just call close from one member. I would try adding:

Set wbks = Nothing

after the Close and before the Quit.

pteranodon
  • 2,037
  • 1
  • 13
  • 20