I would like to use Python to run a macro contained in MacroBook.xlsm on a worksheet in Data.csv.
Normally in excel, I have both files open and shift focus to the Data.csv file and run the macro from MacroBook. The python script downloads the Data.csv file daily, so I can't put the macro in that file.
Here's my code: import win32com.client import os import xl excel = win32com.client.Dispatch("Excel.Application") macrowb = xl.Workbook('C:\MacroBook.xlsm') wb1 = xl.Workbook('C:\Database.csv') excel.Run("FilterLoans")
I get an error, "pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, u'Microsoft Excel', u"Cannot run the macro 'FilterLoans'. The macro may not be available in this workbook or all macros may be disabled.", u'xlmain11.chm', 0, -2146827284), None)"
The error states that FilterLoans is not available in the Database.csv file...how can I import it?