How to launch a MS macro from a VBA program?

General Macro Scheduler discussion

Moderators: Dorian (MJT support), JRL

Post Reply
JPBernoux
Newbie
Posts: 8
Joined: Tue Nov 09, 2004 3:11 pm
Location: Raleigh, NC, USA

How to launch a MS macro from a VBA program?

Post by JPBernoux » Wed Oct 12, 2005 9:53 pm

I have been working a while on this issue going nowhere. Any help would be appreciated. In a nutshell I want to execute a MS macro from a VBA procedure which is part of an Excel sheet. It boils down to:
How to execute VBSript from VBA?
The excellent MS manual shows how to execute VBA from MS macros but I just want to do the opposite...

User avatar
Monkster
Junior Coder
Posts: 42
Joined: Fri Oct 04, 2002 9:37 pm
Location: On an Island with Wilson

Post by Monkster » Thu Oct 13, 2005 3:56 am

The VBA Shell Function should do the trick.

Shell "C:\Program Files\Macro Scheduler\msched.exe myScript.scp", vbNormalFocus

or

Shell "C:\Program Files\Macro Scheduler\msched.exe C:\Temp\myScript.scp", vbMaximizedFocus

etc.
Best Wishes,
Monkster

JPBernoux
Newbie
Posts: 8
Joined: Tue Nov 09, 2004 3:11 pm
Location: Raleigh, NC, USA

Thanks a lot!

Post by JPBernoux » Thu Oct 13, 2005 2:14 pm

I had tried the shell command but directly with my sript which was rejected because it's not an exe. I was not aware of this syntax which makes lots of sense now! Very helpful, thanks!
JP

evangelmike
Pro Scripter
Posts: 56
Joined: Sun May 11, 2008 9:39 pm

Post by evangelmike » Sat Jun 07, 2008 11:38 pm

Greetings! If one does not want a DOS Window to open, one can also use ShellExecute in VBA as follows:

[code]
Private Declare Function ShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" (ByVal hWnd As Long, _
ByVal lpOperation As String, ByVal lpFile As String, _
ByVal lpParameters As String, ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long


FileName = "C:\Documents and Settings\Michael Fitzpatrick\My Documents\Macro Scheduler" & "\SetSTEP_DELAYEnvVar.scp"
Result = ShellExecute(0&, vbNullString, FileName, vbNullString, vbNullString, vbNormalFocus)
[/code]
May you have a blessed day!

Michael D Fitzpatrick
Reg. US Patent Agent

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