I cannot close Excel 2016 after executing a xlwings function

前端 未结 1 845
情深已故
情深已故 2021-02-04 17:58

when I execute a an Xlwings function I can save and close the workbook. But I cannot close Excel 2016 anymore. Is this a known issue? How can I fix this?

相关标签:
1条回答
  • 2021-02-04 18:47

    Here is how I got it to work:

    import xlwings as xw
    wbPath = [WorkbookPath]
    wb = xw.Book(wbPath) 
    app = xw.apps.active    
    wb.save(wbPath)
    #wb.close()
    
    app.quit()
    

    Note that I commented out the line wb.close(). You can skip this step and instead set the app = active Excel instance, save the workbook, and then quit the app.

    0 讨论(0)
提交回复
热议问题