I'm running TIBCO Spotfire v4. It has IronPython built in. Looking to run a Spotfire report that will export a .xls file (that part is done). Looking for a script to open an Excel file and run a macro to be able to format the file.
Here's some code I found and tried using. Not sure where the import items come from!
import os, os.path, win32com.client
def run_macro(fName, macName, path=os.getcwd()):
"""
pre: fName is the name a valid Excel file with macro macName
post: fName!macName is run, fName saved and closed
"""
fName = os.path.join(path, fName)
xlApp = win32com.client.Dispatch("Excel.Application")
fTest = xlApp.Workbooks.Open(fName)
macName = fTest.Name + '!' + macName xlApp.Run(macName)
fTest.Close(1)
xlApp.Quit()
xlApp = None
EDITOR - Code looks to be from Cannot iterate VBA macros from Python.