Automator=>AppleScript=>Excel Macro

Ok, so here is what I am trying to do. I want to open a bunch of excel files and have a VB macro I wrote run on them.

Currently I have automator:
-Get Specified Finder Items (the files I want to run the macro on)
-Open Finder Items
-Run Applescript

on run {input, parameters}

tell application "Microsoft Excel"
run VB macro "macroname"

end tell
end run

I can get this to run on one file, but it won't go through all the open files.

Can someone help me to figure out how to make it run on lots of files? I really don't want to have to repeat this for all 68 files I currently have (there will be more later)..

Thanks.


MacBook Pro Mac OS X (10.4.8)

Posted on Feb 22, 2007 9:49 AM

Reply
4 replies

Feb 22, 2007 10:56 AM in response to astrosquirrelbait

astrosquirrelbait,

I would suggest letting Excel open the files and include a repeat loop to process each file.

1) Get Specified Finder Items
2) Run AppleScript with following script

click here to open this script in your editor <pre style="font-family: 'Monaco', 'Courier New', Courier, monospace; overflow:auto; color: #222; background: #DDD; padding: 0.2em; font-size: 10px; width:400px">on run {input,parameters}

tell application "Microsoft Excel"

repeat with aFile in input
open aFile
run VB macro "macroname"
close aFile
end repeat

end tell

return input

end run</pre>

PowerBook 12" Mac OS X (10.4.8)

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Automator=>AppleScript=>Excel Macro

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.