![]() |
Run macros of excel sheet from python scripts - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Run macros of excel sheet from python scripts (/thread-17955.html) |
Run macros of excel sheet from python scripts - shubhamjainj - May-01-2019 Hello, I am getting the following error while running the macro using python scripts Following is the code used:import win32com.client as win32 excel = win32.Dispatch("Excel.Application") # create an instance of Excel book = excel.Workbooks.Open(Filename=r'C:\Users\workbook1.xlsm') excel.Run('workbook1.xlsm!Grey Scaling.OpenWorkbook') # This runs the macro that is on Sheet1 whose name is Grey Scalling book.Save() book.Close() excel.Quit()Thanks in advance for your help RE: Run macros of excel sheet from python scripts - buran - May-01-2019 try import win32com.client as win32 excel = win32.Dispatch("Excel.Application") # create an instance of Excel book = excel.Workbooks.Open(Filename=r'C:\Users\workbook1.xlsm') excel.Application.Run('workbook1.xlsm!Grey Scaling.OpenWorkbook') # This runs the macro that is on Sheet1 whose name is Grey Scalling book.Save() book.Close() excel.Application.Quit() RE: Run macros of excel sheet from python scripts - shubhamjainj - May-01-2019 Thanks for the reply. I tried above code still getting the same error.
RE: Run macros of excel sheet from python scripts - buran - May-01-2019 what is the macro security setting? |