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 things down. In addition, if the Excel file is unsaved a dialog will mention that the file is already open and that I will lose unsaved changes.
Is there a way to call python without reopening the Excel file?
This is my python code (in loaddf.py):
from xlwings import Workbook, Range, Sheet
def my_macro():
wb = Workbook.caller()
Range('A1').value = Range('A1').value + 1
And the VBA code in my Excel file:
Sub loaddfsub()
RunPython ("import loaddf; loaddf.my_macro()")
End Sub
Thanks for the help.