View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Steve Yandl Steve Yandl is offline
external usenet poster
 
Posts: 284
Default 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