Run vba a macro or function ?

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
SuitedAces
Pro Scripter
Posts: 50
Joined: Thu Feb 21, 2008 9:11 pm

Run vba a macro or function ?

Post by SuitedAces » Mon Feb 25, 2008 5:23 pm

I have written a macro and a function in vba that I want to use in conjucntion with Macro Scheduler.

I am having difficulty converting it to vb script .


Is it possible to run excel vba macros and functions from Macro Scheduler ?

If so how could I return a value running a vba function ?

Can I run them without opening the excel file ?

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

Post by Marcus Tettmar » Mon Feb 25, 2008 5:31 pm

You can either:

1) Call an Excel macro:
http://www.mjtnet.com/forum/viewtopic.php?t=3825

2) Convert the Excel VBA to VBScript. All references to Excel objects will have to be created using CreateObject. (Code in Excel knows about Excel. Code outside of Excel doesn't until you tell it). Search here for CreateObject("Excel.Application"). Also some samples with the software and here: http://www.mjtnet.com/blog/2007/07/02/m ... xcel-data/
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

SuitedAces
Pro Scripter
Posts: 50
Joined: Thu Feb 21, 2008 9:11 pm

Post by SuitedAces » Mon Feb 25, 2008 6:23 pm

Thanks for your reply.

Hopefully the first option will provide the solution .

I tinkered around with converting my vba code to vb script .
I ran my vba code in the editor between the vb tags commenting out the code and adding a few lines at a time to see what ended up generating errors.

The task of converting to vb script seems to require a substantail learning curve. An example being goto doesn't exist in vb script and I would need to rewrite all my loops .

How can I go about passing argument to the macro or function and passing values back to my script when I run my vba macro or function according to your example ?

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