Notice your syntax:
"FirstFile.xls!SameMacroButStoredInThisSpecificWorkbook"
You have an exclamation mark after the workbook name and you use the workbook
name.
Application.Run "'" & wbk.name & "'!SameMacroButStoredInThisSpecificWorkbook"
The apostrophes are sometimes required--depending on the name of the file. But
they never hurt if you include them.
(E-Mail Removed) wrote:
>
> Hi guys,
>
> One question:
>
> Do you know how to convert the macro:
>
> Sub UglyMacro ()
> Application.Run
> "FirstFile.xls!SameMacroButStoredInThisSpecificWorkbook"
> ActiveWindow.ActivateNext
> Application.Run
> "SecondFile.xls!SameMacroButStoredInThisSpecificWorkbook"
> ActiveWindow.ActivateNext
> Application.Run
> "ThirdFile.xls!SameMacroButStoredInThisSpecificWorkbook"
> ActiveWindow.ActivateNext
> End Sub
>
> into macro that will go like:
>
> Sub DraftNiceMacro ()
> For each wbk in Application.Workbooks
> Application.Run "wbk.SameMacroButStoredInThisSpecificWorkbook"
> Next wbk
> End Sub
>
> This one is not working for some strange reason...
>
> Thanks for your help,
> Mark
--
Dave Peterson