Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Creating a macro that opens and runs multiple workbooks and macros

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.

  #2   Report Post  
Posted to microsoft.public.excel.programming
N10 N10 is offline
external usenet poster
 
Posts: 141
Default Creating a macro that opens and runs multiple workbooks and macros


wrote in message
ups.com...
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 :)


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Creating a macro that opens and runs multiple workbooks and macros

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?

" wrote:

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.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
I need a macro that runs other macros until P5=28 Jeff Excel Discussion (Misc queries) 6 May 7th 08 11:44 PM
Need Help Creating a Macro Multiple Workbooks to One Howeecow Excel Worksheet Functions 1 June 7th 07 06:20 PM
How to stop other macros while current macro runs Paul987[_23_] Excel Programming 2 April 24th 06 05:15 PM
VLookUp when Macro Opens WorkBooks Tom Ogilvy Excel Programming 1 August 26th 04 05:25 AM
VLookUp when Macro Opens WorkBooks Jim Thomlinson[_3_] Excel Programming 2 August 26th 04 05:21 AM


All times are GMT +1. The time now is 03:19 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"