Run a VBA Sub using Windows Scheduler?

J

JK

Does anyone know (if it's even possible) how to run a VBA sub using the
Windows Scheduler?

I pull data from our main company database (J.D. Edwards) and then import
the data into my db every night. I run a series of make table queries and
update/append queries.

I previously accomplished this using a macro but I'm having trouble working
with macos on my computer. I'd like to convert all macros to VBA.

Thanks,
Jason
 
J

Jack Leach

Aside from using a Macro I do not think this is possible.

On the plus side, though, if you are doing these tasks in macros and want to
convert them all to VBA, do that, and then use a one-line RunCode macro to
call the function that contains your actual code. Then you can effectively
run a function from an external shortcut to a macro.


Ex:

Public Function DoThings(ThisArg, ThatArg)
'put all of the code you want to run here
End Function

then make a macro:

RunCode
=DoThings("somearg", "somearg")


then make your macro shortcut to call from the scheduler.


hth

--
Jack Leach
www.tristatemachine.com

"I haven't failed, I've found ten thousand ways that don't work."
-Thomas Edison (1847-1931)
 
D

Dirk Goldgar

JK said:
Does anyone know (if it's even possible) how to run a VBA sub using the
Windows Scheduler?

I pull data from our main company database (J.D. Edwards) and then import
the data into my db every night. I run a series of make table queries and
update/append queries.

I previously accomplished this using a macro but I'm having trouble
working
with macos on my computer. I'd like to convert all macros to VBA.


You can't directly call a VBA procedure from the command line, which is what
you need to do via the scheduler. You can have very simple macro that just
uses the RunCode action to run a VBA Function (not a Sub), and invoke that
macro from the command line.

Or you could have a startup form with an Open event procedure that checks
the value of a string argument passed from the command line, and executes
your Sub if that argument has a special value. You'd pass the argument via
the /cmd command-line switch, and use the Command() function in your event
procedure to retrieve the argument.
 
M

mcescher

Does anyone know (if it's even possible) how to run a VBA sub using the
Windows Scheduler?

I pull data from our main company database (J.D. Edwards) and then import
the data into my db every night. I run a series of make table queries and
update/append queries.

I previously accomplished this using a macro but I'm having trouble working
with macos on my computer. I'd like to convert all macros to VBA.

Thanks,
Jason

You could have a form load and the OnLoad code could do your import
function. That would also give you the option of displaying any
feedback, and/or having a manual import button.

To open a form automatically: Tools, Startup, Display Form/Page

Hope this helps,
Chris M.
 
J

Judy Ward

I realize that I am replying to this post 5 months later but wanted you to
know how ecstatic I am to find your answer. I was struggling to make this
work on my own. Your solution is simple (easy to use) and it works!!!

Thank you very much!
Judy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top