Using Office 2003 and Windows XP;

Could someone please post generic example code that illustrates how to run a
stand alone *.vbs file from MS-Access and/or MS-Excel (I would presume the
same method would work for either)?

Thanks much in advance.

Re: Run a *.vbs file from MS-Access or MS-Excel by mr_unreliable

mr_unreliable
Wed Apr 04 11:21:53 CDT 2007

hi XP,

Try the "shell" function.

Go to the "tools" => "visual basic editor" and write yourself
a macro, having the shell function which will run your script.

Like this:

Call Shell("myPath\myScript.vbs myArguments")

To get the macro to run, you are going to have to hook it to
a command button, place it in an "Auto" type macro, or some
other event to initiate your macro.

cheers, jw
____________________________________________________________

You got questions? WE GOT ANSWERS!!! ..(but,
no guarantee the answers will be applicable to the questions)



XP wrote:
> Using Office 2003 and Windows XP;
>
> Could someone please post generic example code that illustrates how to run a
> stand alone *.vbs file from MS-Access and/or MS-Excel (I would presume the
> same method would work for either)?
>
> Thanks much in advance.

Re: Run a *.vbs file from MS-Access or MS-Excel by XP

XP
Wed Apr 04 11:46:03 CDT 2007

That is what I thought, but when I use the Shell method in MS-Access I get
error:

Invalid procedure call or argument

Any idea what's going on here?

The path and file name are solid...and outside of that it doesn't seem there
is too much that could go wrong...but I'm getting the error; I could actually
open it using the FollowHyperlink method but this opens an unsupressable
warning message so I don't like that...how can I get shell to work?

"mr_unreliable" wrote:

> hi XP,
>
> Try the "shell" function.
>
> Go to the "tools" => "visual basic editor" and write yourself
> a macro, having the shell function which will run your script.
>
> Like this:
>
> Call Shell("myPath\myScript.vbs myArguments")
>
> To get the macro to run, you are going to have to hook it to
> a command button, place it in an "Auto" type macro, or some
> other event to initiate your macro.
>
> cheers, jw
> ____________________________________________________________
>
> You got questions? WE GOT ANSWERS!!! ..(but,
> no guarantee the answers will be applicable to the questions)
>
>
>
> XP wrote:
> > Using Office 2003 and Windows XP;
> >
> > Could someone please post generic example code that illustrates how to run a
> > stand alone *.vbs file from MS-Access and/or MS-Excel (I would presume the
> > same method would work for either)?
> >
> > Thanks much in advance.
>

Re: Run a *.vbs file from MS-Access or MS-Excel by mr_unreliable

mr_unreliable
Wed Apr 04 13:25:15 CDT 2007

xp, is there a "blank" (character) in either the path
or the filename?

cheers, jw

XP wrote:
> That is what I thought, but when I use the Shell method in MS-Access I get
> error:
>
> Invalid procedure call or argument
>
> Any idea what's going on here?
>
> The path and file name are solid...and outside of that it doesn't seem there
> is too much that could go wrong...but I'm getting the error; I could actually
> open it using the FollowHyperlink method but this opens an unsupressable
> warning message so I don't like that...how can I get shell to work?
>
> "mr_unreliable" wrote:
>
>> hi XP,
>>
>> Try the "shell" function.
>>
>> Go to the "tools" => "visual basic editor" and write yourself
>> a macro, having the shell function which will run your script.
>>
>> Like this:
>>
>> Call Shell("myPath\myScript.vbs myArguments")
>>
>> To get the macro to run, you are going to have to hook it to
>> a command button, place it in an "Auto" type macro, or some
>> other event to initiate your macro.
>>
>> cheers, jw
>> ____________________________________________________________
>>
>> You got questions? WE GOT ANSWERS!!! ..(but,
>> no guarantee the answers will be applicable to the questions)
>>
>>
>>
>> XP wrote:
>>> Using Office 2003 and Windows XP;
>>>
>>> Could someone please post generic example code that illustrates how to run a
>>> stand alone *.vbs file from MS-Access and/or MS-Excel (I would presume the
>>> same method would work for either)?
>>>
>>> Thanks much in advance.

Re: Run a *.vbs file from MS-Access or MS-Excel by Marcus

Marcus
Wed Apr 04 14:22:24 CDT 2007

Try


YourScript = "C:\Somewhere\Something.vbs"
Shell "C:\WinNT\System32\Wscript.exe " & Chr(34) & YourScript & Chr(34)

(replace WinNT with you Windows Directory)



XP schrieb:
> That is what I thought, but when I use the Shell method in MS-Access I get
> error:
>
> Invalid procedure call or argument
>
> Any idea what's going on here?
>
> The path and file name are solid...and outside of that it doesn't seem there
> is too much that could go wrong...but I'm getting the error; I could actually
> open it using the FollowHyperlink method but this opens an unsupressable
> warning message so I don't like that...how can I get shell to work?
>
> "mr_unreliable" wrote:
>
>> hi XP,
>>
>> Try the "shell" function.
>>
>> Go to the "tools" => "visual basic editor" and write yourself
>> a macro, having the shell function which will run your script.
>>
>> Like this:
>>
>> Call Shell("myPath\myScript.vbs myArguments")
>>
>> To get the macro to run, you are going to have to hook it to
>> a command button, place it in an "Auto" type macro, or some
>> other event to initiate your macro.
>>
>> cheers, jw
>> ____________________________________________________________
>>
>> You got questions? WE GOT ANSWERS!!! ..(but,
>> no guarantee the answers will be applicable to the questions)
>>
>>
>>
>> XP wrote:
>>> Using Office 2003 and Windows XP;
>>>
>>> Could someone please post generic example code that illustrates how to run a
>>> stand alone *.vbs file from MS-Access and/or MS-Excel (I would presume the
>>> same method would work for either)?
>>>
>>> Thanks much in advance.

Re: Run a *.vbs file from MS-Access or MS-Excel by mr_unreliable

mr_unreliable
Wed Apr 04 15:00:48 CDT 2007

If "vbs" is registered as a file extension, and if the
default member is "open", and if "open" is setup to call
wscript to run the vbs file, then the "wscript.exe" in
front of the script file name "ought to" not be necessary.

mfg, jw

Marcus Schmitt wrote:
> Try
>
> YourScript = "C:\Somewhere\Something.vbs"
> Shell "C:\WinNT\System32\Wscript.exe " & Chr(34) & YourScript & Chr(34)
>

Re: Run a *.vbs file from MS-Access or MS-Excel by XP

XP
Wed Apr 04 17:46:00 CDT 2007

Hi,

Cracked it with everyone's help; yes, there were spaces at the network level
of the path - I forgot all about this issue; here is what finally worked:

Shell "WScript " & """MyPath\MyScript.vbs"""

Thanks for all the time and assistance - could not see the problem without
your input!

"mr_unreliable" wrote:

> If "vbs" is registered as a file extension, and if the
> default member is "open", and if "open" is setup to call
> wscript to run the vbs file, then the "wscript.exe" in
> front of the script file name "ought to" not be necessary.
>
> mfg, jw
>
> Marcus Schmitt wrote:
> > Try
> >
> > YourScript = "C:\Somewhere\Something.vbs"
> > Shell "C:\WinNT\System32\Wscript.exe " & Chr(34) & YourScript & Chr(34)
> >
>