0

I have the following python code that opens my excel file and closes it; however, the Excel app remains open. I have other python script running in the background so I only want to close the application it opened when it opened the file (not all running Excel applications).

xlapp = win32com.client.DispatchEx("Excel.Application")
xlapp.DisplayAlerts = False
xlapp.Visible = True
wb = xlapp.Workbooks.Open(file_path)


if refresh1 == True:
    wb.RefreshAll()
    xlapp.CalculateUntilAsyncQueriesDone()

wb.Save
wb.SaveAs(yestmoPath, FileFormat="51")
wb.close

I tried xlapp.quit at the end and receive this message: <bound method quit of >

CR130
  • 98
  • 7
slc1axj
  • 13
  • 4

1 Answers1

0

The only way I figured it out was to import xlwings as follows:

import xlwings as xw

then at the end, I placed the code:

book = xw.Book()
book.app.quit()
lepsch
  • 8,927
  • 5
  • 24
  • 44
slc1axj
  • 13
  • 4