Is there a way to call python with xlwings without reopening the Excel file?

后端 未结 1 427
日久生厌
日久生厌 2021-01-05 00:51

I am calling python from Excel using xlwings. I find that when running my macro, Excel closes and reopens in order to run the code. It functions correctly but it slows thing

相关标签:
1条回答
  • 2021-01-05 01:35

    It seems that under certain circumstances, Excel doesn't register an Excel Workbook properly in the RunningObjectTable, a precondition so it can be found via COM. So far I've only noticed this behaviour for Workbooks downloaded from the internet given it opens them in the Protected View mode first (depends on Settings). However, based on the feedback here, it seems that it can also happen under other circumstances, possibly caused by some add-ins or security settings.

    I've implemented a fix for this which will be present in v0.3.1, but you can get it right now directly from GitHub. Let me know if you need help there.

    Update (16-Jan-2015): xlwings v0.3.1 including this fix has just been released.

    Update2 (13-Sept-2015): xlwings v0.4.0 should finally fix this bug in a reliable way.

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