How can I close excel aplication completely in word vba?
Dim ExcelApp As Object, ExcelBook As Object Set ExcelApp = CreateObject("excel.Application") Set ExcelBook = ExcelApp.Workbooks.Open(ActiveDocument.Path & "\data.xls") 'ExcelApp.Visible = True/False ExcelApp.DisplayAlerts = False 'something with ExcelBook, just editing cells ExcelBook.Close savechanges:=True Excel.Application.Quit Set ExcelBook = Nothing Set ExcelApp = Nothing
When I open taskmanager there is still proces EXCEL running. Problem is, that I need to run macro multiple times and than my data.xls – excel file can be open read only.
You need to quit the instance you started. Replace
I find out why I had this problem. While running code that uses Automation to control Microsoft Excel, Visual Basic does not release reference until you end the program.
When I close word, excel process is closed as well.
More info here: