I am trying to run vba macro from Python but the excel file which has macro is already open. So I want to not open it again as another instance.
I have tried win32com code - however it reopens another instance of the same file and makes changes in that instance and ask me to save as second excel file. But i want to call macro in already open file. and after calling that macro leave the excel file open. this is the path where File is located - its a private shared drive
\nplofnp0001a\gtonnnfs10912400\CPM Other\PL Estimate\PL Estimate Sheets\DAILY PL ESTIMATE W NRPD RV2 v6_YK_v2.xlsm
folder_xlfile = '\\\\nplofnp0001a\gtonnnfs10912400\CPM Other\PL Estimate\PL Estimate Sheets'
xlfile = '\\DAILY PL ESTIMATE W NRPD RV2 v6_YK_v2.xlsm'
Filename=folder_xlfile + xlfile
import win32com.client
xl=win32com.client.DispatchEx("Excel.Application")
#wb = xl.Workbooks.Open(Filename)
xl.Application.Run(Filename + "!Module2.CopySummaryData")
#xl.Application.Quit()
del xl
Expected Result - run vba function in already open excelfile.
Actual Result - just keeps running without error message. I guess code hangs.