PC Review


Reply
Thread Tools Rate Thread

Creating a macro that opens and runs multiple workbooks and macros

 
 
dougban99@yahoo.com
Guest
Posts: n/a
 
      19th Jun 2007
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 With Quote
 
 
 
 
N10
Guest
Posts: n/a
 
      19th Jun 2007

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>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


 
Reply With Quote
 
=?Utf-8?B?QmFyYiBSZWluaGFyZHQ=?=
Guest
Posts: n/a
 
      20th Jun 2007
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?

"(E-Mail Removed)" 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
A workbook of macros which runs on external workbooks. Lostguy Microsoft Excel Programming 6 8th Jul 2008 01:01 PM
I need a macro that runs other macros until P5>=28 Jeff Microsoft Excel Misc 6 7th May 2008 11:44 PM
Need Help Creating a Macro Multiple Workbooks to One =?Utf-8?B?SG93ZWVjb3c=?= Microsoft Excel Worksheet Functions 1 7th Jun 2007 06:20 PM
How to stop other macros while current macro runs Paul987 Microsoft Excel Programming 2 24th Apr 2006 05:15 PM
creating workbooks(with macros and userforms) programmatically amitkr Microsoft Excel Programming 2 21st Jun 2004 12:10 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:00 PM.