View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Cajeto 63 Cajeto 63 is offline
external usenet poster
 
Posts: 26
Default Launch VBS from VBA

Chip,
I have one last question for you,
I downloaded the self contained "modShellAndWaitSimple.bas" module but I am
not sure how I integrate it to my code.

Shall I call the function before the Shell command or within the Shell
command and if so how or ???

Can you help?


--


Regards, Cajeto 63.





"Chip Pearson" wrote:

"NickHK" wrote in message

I can't test if they work with UNC paths


They do. E.g.,

Shell "WScript.exe \\DellLapTop2\MainDrive\Test.vbs"

If you need to wait for the script to finish before continuing with your VBA
code, see http://www.cpearson.com/excel/shellandwait.htm for two procedures,
ShellAndWaitSimple and ShellAndWaitEnhanced, that will cause your VBA code
to wait until the Shell command completes before continuing.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)

"NickHK" wrote in message
...

Dim Retval
Retval = Shell("WScript.exe C:\Test.vbs")
or
Retval = Shell("CScript.exe C:\Test.vbs")

There is difference between the W and C script engines, but forget the
nuances now
I can't test if they work with UNC paths

NickHK

"Cajeto 63" wrote in message
...
Hello,

I'm trying to launch a VBS from excel using the code below:

Dim Retval
RetVal = Shell("cmd / u:\windowsu:\Formation\DataSet
Vision\VBscriptXL_Vision\ImportDonnéesTest.vbs")

but it does not work although the vbs works perfectly when launched "by

hand"

Instead of running the script it opens a cmd windows giving the following
message:
" CMD.EXE was started with the path "\\myserver\myname\my documents" as

the
current directory. UNC paths are not supported. Defaulting to windows
directory."

Any help to solve this issue would be very highly appreciated.

Thank you.
--


Regards, Cajeto 63.