First time here? We are a friendly community of Power Systems Engineers. Check out the FAQ!
1 | initial version |
I've done this a few times actually. What I end up doing is closing the file via excelPy, and then reopening it with win32com, and running the macro there. Assuming your macro name is "MacroName", your excel file is "xlsfile" and it is located at "THISFOLDER":
# Close excel file
testxls = excelpy.workbook(xlsfile)
testxls.close()
# Open excel file via win32com
import win32com.client as win32
xl = win32.Dispatch('Excel.Application')
xl.Visible = True
ss = xl.Workbooks.Open(THISFOLDER + "\\" + xlsfile)
xl.Run("MacroName")