Join the Stack Overflow Community
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

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
share|improve this question
2  
The second occurrence of the line xl.Workbooks.Open(Filename="path) is missing a quote after path. – aneroid 19 hours ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.