I am using Python and the win32com.client library to run a VBA macro. The macro requires a directory (which is a substring of the .xlsm path itself). How do I pass this directory/string to the VBA popup?
import os, os.path
import win32com.client
if os.path.exists('C:/test_folder/excel_file.xlsm'):
xl=win32com.client.Dispatch("Excel.Application")
xl.Workbooks.Open('C:/test_folder/excel_file.xlsm', ReadOnly=1)
xl.Application.Run('excel_file.xlsm!Sheet1.Macro1')
After this code is run, the folder explorer window pops up asking for a directory. How would I pass the directory to Excel?