I'm trying to run a Personal Workbook Macro from Python with 0 arguments. So far, this is my code:
xl = win32com.client.Dispatch("Excel.application")
xl.Visible = 1
if os.path.isfile('delete_this_file.xlsx'):
workbook = xl.Workbooks.Open('delete_this_file.xlsx')
else:
workbook = xl.Workbooks.Add()
workbook.SaveAs(os.getcwd() + '\\delete_this_file.xlsx')
xl.Workbooks.Add("C:\\Users\\myusername\\AppData\\Roaming\\Microsoft\\Excel\\XLSTART\\PERSONAL.XLSB")
xl.Application.Run('LoopThruFiles')
xl.DisplayAlerts = 0
xl.Application.Quit()
del xl
But Python kicks back the Windows error: "Cannot run the macro 'LoopThruFiles'. The macro may not be available in this workbook or all macros may be disabled."
However, I have enabled the "Trust access to the VBA project object model" checkbox in the Trust center.
Anyone have any experience with this?