ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Wscript.Shell Run vbs Fails? (https://www.excelbanter.com/excel-programming/399235-wscript-shell-run-vbs-fails.html)

RayportingMonkey

Wscript.Shell Run vbs Fails?
 
OK - What am I doing wrong?

'Move Files To Their Archive Locations
Dim movScrpt As Object
Set movScrpt = CreateObject("Wscript.Shell")
movScrpt.Run "\\ServerName\Enterprise Forecasting & Scheduling
Team\MoveReports.vbs"


I get a Run-Time error '-2147024894(80070002)':
Method 'Run' of object 'IWshShell3' failed

Steve Yandl

Wscript.Shell Run vbs Fails?
 
You might want to check VBA's help regarding the 'Shell' function. That
would probably be a better option that having to create an instance of
"Wscript.Shell". In fact, if your vbs file is simply using the
"Scripting.FileSystemObject" to move files, you might consider doing the
same thing from within VBA and avoid messing with the vbs file.

To answer your question though, whether you use WScript.Shell or the Shell
function, the executable you want to run is either wscript.exe or
cscript.exe with the vbs file passed to the executable as an argument.

Steve



"RayportingMonkey" wrote in
message ...
OK - What am I doing wrong?

'Move Files To Their Archive Locations
Dim movScrpt As Object
Set movScrpt = CreateObject("Wscript.Shell")
movScrpt.Run "\\ServerName\Enterprise Forecasting & Scheduling
Team\MoveReports.vbs"


I get a Run-Time error '-2147024894(80070002)':
Method 'Run' of object 'IWshShell3' failed





All times are GMT +1. The time now is 12:24 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com