I am trying to open 1st macro, close and run 2nd macro, and so on. Followings are my code to run 2 excel macro files sequentially. I got a error message as "Traceback (most recent call last):~~~~~ AttributeError: Excel.Application.Workbooks"
It would be much appreciate if someone can advise me. Thank you.
import os
import win32com.client
xl=win32com.client.Dispatch("Excel.Application")
xl.Visible = True
xl.Workbooks.Open(Filename="path")
xl.Application.Run("layer1.xlsm!Sheet4.CommandButton1_Click")
prob = xl.Cells(19,2).Value
xl.Application.Quit()
del xl
############# Try to open 2nd excel file #####################
xl=win32com.client.Dispatch("Excel.Application")
xl.Workbooks.Open(Filename="path")
xl.Application.Run("layer2.xlsm!Sheet4.CommandButton1_Click")
xl.Application.Quit()
del xl
xl.Workbooks.Open(Filename="path)
is missing a quote afterpath
. – aneroid 19 hours ago