Nedd help to run multiple macros - Urgent!!!!!!!!!!!!!!

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
Naresh
Newbie
Posts: 1
Joined: Tue Mar 25, 2008 4:13 pm

Nedd help to run multiple macros - Urgent!!!!!!!!!!!!!!

Post by Naresh » Thu Mar 27, 2008 4:52 pm

Hi,
I got a script which can open an excel sheet & run a macro. I want the script to run more than one macro in that paricular sheet.
I am pasting the script below. Cn anyone help on this



//Put this VBScript block at top of script
VBSTART
Sub OpenAndRun(xlFileName, MacroName)
Set xlApp = CreateObject("Excel.Application")
'remove next line to make Excel invisible
xlApp.visible = true
Set xlBook = xlApp.WorkBooks.Open(xlFileName)
xlApp.Run(MacroName)
'Uncomment next line to quit Excel
'xlApp.quit
End Sub
VBEND


//Use this line when you want to run the Excel macro:
VBRun>OpenAndRun,C:\Documents and Settings\wedws\Desktop\excel.xls,Macro1[/b]
[/code]

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Thu Mar 27, 2008 6:12 pm

Just add more of these lines:

xlApp.Run(MacroName)

As many as you like.

You may want to split the VBScript into two/three functions - one to open the Excel book, one to run all the macros, one to close the book.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts