Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBScript from VBA excel / wshShell.Run failed, error 80070483
hi,
i am trying to run a vb script from a VBA module in excel. fn = "test.vbs Set wshShell = CreateObject("Wscript.Shell") wshShell.Run (fn) in the line wshShell.Run (fn) i obtain an error error 80070483 method Run of object IWshShell3 failed it is the first time i do this, so i am not shure if i need to have done something before, some references??? in windows extension .vbs is not related to any application (is it ok???) tks in advance |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBScript from VBA excel / wshShell.Run failed, error 80070483
Maybe its just the path:
Sub samples() fn = "C:\hithere.vbs" Set wshShell = CreateObject("Wscript.Shell") wshShell.Run (fn) End Sub works just fine. -- Gary''s Student - gsnu200730 "rhXX" wrote: hi, i am trying to run a vb script from a VBA module in excel. fn = "test.vbs Set wshShell = CreateObject("Wscript.Shell") wshShell.Run (fn) in the line wshShell.Run (fn) i obtain an error error 80070483 method Run of object IWshShell3 failed it is the first time i do this, so i am not shure if i need to have done something before, some references??? in windows extension .vbs is not related to any application (is it ok???) tks in advance |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBScript from VBA excel / wshShell.Run failed, error 80070483
On Jun 17, 3:37 pm, Gary''s Student
wrote: Maybe its just the path: Sub samples() fn = "C:\hithere.vbs" Set wshShell = CreateObject("Wscript.Shell") wshShell.Run (fn) End Sub works just fine. tks, but i think there is other problem my sub is: Sub bypass() fn = "c:\tmp\bypass.vbs" Set fso = CreateObject("Scripting.FileSystemObject") Set fsoFile = fso.CreateTextFile(fn) fsoFile.WriteLine "Set fso = CreateTextFile(""c:\tmp \toto.txt"")" fsoFile.WriteLine "fsoFile.WriteLine ""Hello world""" fsoFile.WriteLine "fsoFile.Close" fsoFile.Close Set wshShell = CreateObject("Wscript.Shell") wshShell.Run (fn) End Sub the bypass file was created ok: Set fso = CreateTextFile("c:\tmp\toto.txt") fsoFile.WriteLine "Hello world" fsoFile.Close the error is in the line wshShell.Run (fn) and the file toto.txt, wich must be created by the vbscript was not created question: when i try to run the vbscript by hand, it does not run because .vbs extension is NOT associated by any application. is this ok???? tks in advance |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBScript from VBA excel / wshShell.Run failed, error 80070483
Not O.K.
from any folder: Tools Folder Options File Types and then register .vbs with the Microsoft (r) Windows Based Script Host -- Gary''s Student - gsnu200730 "rhXX" wrote: On Jun 17, 3:37 pm, Gary''s Student wrote: Maybe its just the path: Sub samples() fn = "C:\hithere.vbs" Set wshShell = CreateObject("Wscript.Shell") wshShell.Run (fn) End Sub works just fine. tks, but i think there is other problem my sub is: Sub bypass() fn = "c:\tmp\bypass.vbs" Set fso = CreateObject("Scripting.FileSystemObject") Set fsoFile = fso.CreateTextFile(fn) fsoFile.WriteLine "Set fso = CreateTextFile(""c:\tmp \toto.txt"")" fsoFile.WriteLine "fsoFile.WriteLine ""Hello world""" fsoFile.WriteLine "fsoFile.Close" fsoFile.Close Set wshShell = CreateObject("Wscript.Shell") wshShell.Run (fn) End Sub the bypass file was created ok: Set fso = CreateTextFile("c:\tmp\toto.txt") fsoFile.WriteLine "Hello world" fsoFile.Close the error is in the line wshShell.Run (fn) and the file toto.txt, wich must be created by the vbscript was not created question: when i try to run the vbscript by hand, it does not run because .vbs extension is NOT associated by any application. is this ok???? tks in advance |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBScript from VBA excel / wshShell.Run failed, error 80070483
If you're not needing the "WScript.Shell" object for any other reason than
launching your vbs file, you could just use the 'Shell' function within VBA. Either way, you need to launch either WScript.exe or CScript.exe and pass the path to your vbs file to the executable as an argument rather than trying to "run" the vbs file. Steve Yandl "rhXX" wrote in message ups.com... On Jun 17, 3:37 pm, Gary''s Student wrote: Maybe its just the path: Sub samples() fn = "C:\hithere.vbs" Set wshShell = CreateObject("Wscript.Shell") wshShell.Run (fn) End Sub works just fine. tks, but i think there is other problem my sub is: Sub bypass() fn = "c:\tmp\bypass.vbs" Set fso = CreateObject("Scripting.FileSystemObject") Set fsoFile = fso.CreateTextFile(fn) fsoFile.WriteLine "Set fso = CreateTextFile(""c:\tmp \toto.txt"")" fsoFile.WriteLine "fsoFile.WriteLine ""Hello world""" fsoFile.WriteLine "fsoFile.Close" fsoFile.Close Set wshShell = CreateObject("Wscript.Shell") wshShell.Run (fn) End Sub the bypass file was created ok: Set fso = CreateTextFile("c:\tmp\toto.txt") fsoFile.WriteLine "Hello world" fsoFile.Close the error is in the line wshShell.Run (fn) and the file toto.txt, wich must be created by the vbscript was not created question: when i try to run the vbscript by hand, it does not run because .vbs extension is NOT associated by any application. is this ok???? tks in advance |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBScript from VBA excel / wshShell.Run failed, error 80070483
If you're not needing the "WScript.Shell" object for any other reason than
launching your vbs file, you could just use the 'Shell' function within VBA. Either way, you need to launch either WScript.exe or CScript.exe and pass the path to your vbs file to the executable as an argument rather than trying to "run" the vbs file. Steve Yandl Not O.K. from any folder: Tools Folder Options File Types and then register .vbs with the Microsoft (r) Windows Based Script Host -- Gary''s Student - gsnu200730 gary / steve, tks a lot! gary after i sent the mail, i tested to register .vbs with some program, i found .vbe, and i done "an equivalent not encoced" VBScript Script File open: C:\WINDOWS\System32\WScript.exe "%1" %* and worked fine! i will check Microsoft (r) Windows Based Script Host steve, i like more ur method, so is indepent from any previus register. i will check now tks again to all!!! |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBScript from VBA excel / wshShell.Run failed, error 80070483
"rhXX" wrote:
gary / steve, tks a lot! gary after i sent the mail, i tested to register .vbs with some program, i found .vbe, and i done "an equivalent not encoced" VBScript Script File open: C:\WINDOWS\System32\WScript.exe "%1" %* and worked fine! i will check Microsoft (r) Windows Based Script Host steve, i like more ur method, so is indepent from any previus register. i will check now tks again to all!!! I think you also have a problem with your bypass.vbs. It should look something like this: Set fso = CreateObject ("Scripting.FileSystemObject") Set fsoFile = fso.CreateTextFile("c:\tmp\toto.txt") fsoFile.WriteLine "Hello world" fsoFile.Close So your sub could look like this: Sub bypass() fn = "c:\tmp\bypass.vbs" Set fso = CreateObject("Scripting.FileSystemObject") Set fsoFile = fso.CreateTextFile(fn) fsoFile.WriteLine "Set fso = CreateObject (""Scripting.FileSystemObject"")" fsoFile.WriteLine "Set fsoFile = fso.CreateTextFile(""c:\tmp\toto.txt"")" fsoFile.WriteLine "fsoFile.WriteLine ""Hello world""" fsoFile.WriteLine "fsoFile.Close" fsoFile.Close 'Set wshShell = CreateObject("Wscript.Shell") 'wshShell.Run ("C:\WINDOWS\system32\Wscript.exe " & fn) Shell "C:\WINDOWS\system32\Wscript.exe " & fn, vbHide End Sub Both wshShell.Run and Shell will do if you pass in the name of the executable (in my case "C:\WINDOWS\system32\Wscript.exe ") followed by the script name ("c:\tmp\bypass.vbs"). If you register .vbs file type to be opened by WSH executable you can use wshShell.Run (fn) without having to specify the name of the WSH executable. Hope this is of some help. -- urkec |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBScript from VBA excel / wshShell.Run failed, error 80070483
'Set wshShell = CreateObject("Wscript.Shell")
'wshShell.Run ("C:\WINDOWS\system32\Wscript.exe " & fn) Shell "C:\WINDOWS\system32\Wscript.exe " & fn, vbHide Both wshShell.Run and Shell will do if you pass in the name of the executable (in my case "C:\WINDOWS\system32\Wscript.exe ") followed by the script name ("c:\tmp\bypass.vbs"). If you register .vbs file type to be opened by WSH executable you can use wshShell.Run (fn) without having to specify the name of the WSH executable. urkec tks urkec, yes i did found a mistake of my first bypass, i wrote directly to forum and noto copy and paste ... ok about wshSell.Run and Shell, now they are working ok writting explicity Wscript.exe tks a lot for the help! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
IWshRuntimeLibrary.WshShell.SpecialFolders requires a variant argument | Excel Programming | |||
Excel 97 error: 'Copy method of range class failed' | Excel Programming | |||
Wshshell / VB direction question | Excel Programming | |||
Error Excel: 1004 SaveAs method of Workbook class failed | Excel Programming | |||
HELP!! Excel 2000 Copy of worksheet class failed run time Error 1004 | Excel Programming |