Creating a macro that opens and runs multiple workbooks and macros

D

dougban99

I have created 10 separate workbooks, each with its own macro. I want
to create one macro that opens each workbook, runs the macro, then
closes the workbook and the moves to the next workbook.

Currently, my code is simple.

Workbooks.open filename
application.run filename!macro
workbook.close

Workbooks.open filename
application.run filename!macro
workbook.close

etc...

the macro is stopping after it completes the first macro.

Any help would be appreciated.
 
N

N10

I have created 10 separate workbooks, each with its own macro. I want
to create one macro that opens each workbook, runs the macro, then
closes the workbook and the moves to the next workbook.

Currently, my code is simple.

Workbooks.open filename
application.run filename!macro
workbook.close

Workbooks.open filename
application.run filename!macro
workbook.close

etc...

the macro is stopping after it completes the first macro.

Any help would be appreciated.


HI

Have you tried putting the macro you want to run in each seprate workbook in
the work book open events of those objects.

The macros would then run automatically everytime the workbook was opened.



N10 :)
 
B

Barb Reinhardt

How about doing something like this

Dim oWB as workbook

set oWB = Workbooks.open filename
application.run filename!macro(oWB) 'Pass oWB to the macro
owb.close

How do you loop through each filename?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top