I have a sheet that contains a macro (.xlsm). When this macro is ran, it requires to select another .csv file and this creates an .xlsx file. So far, I managed to open the .xlsm file and run the macro, but I do not know how to make it choose a specific .csv file and how to save that results.
My code is:
import win32com.client import os directory = "C:/Users/aprofir/Desktop/" file = "CSVDE OPEN.xlsm" macro = "Csvde" path = os.path.join(directory, file) if os.path.exists(path): xlApp = win32com.client.Dispatch("Excel.Application") wb = xlApp.Workbooks.Open(Filename=path, ReadOnly=1) xlApp.Application.Run(macro) xlApp.Application.Run() wb.Close(SaveChanges=1) xlApp.Application.Quit()
If I run this code, the macro wants me to choose a file:
How do I make it select the file at a specific location?</div