Python untuk menjalankan Excel Macro

from win32com.client import Dispatch


def run_excel_macro():
    try:
        excel = Dispatch("Excel.Application")
        excel.Visible = True
        workbook = excel.Workbooks.Open(
            r"D:\Documents\Book1.xlsm")

        workbook.Application.Run("Module1.Example")
        workbook.SaveAs(r"D:\Documents\Book5.xlsm")
        excel.Quit()
    except IOError:
        print("Error")


if __name__ == "__main__":
    run_excel_macro()
Sounkalo traoré