2

Hi can anyone tell me how to execute my .vbs from within VBA cause the following code dose not work.

RetBat4 = Shell("c:\VTS\QUEEN ANNES REVENGE\SYSTEM\VBS\UNDO_2.vbs", 1)

VBA debug says that the sytax is wrong????

thanks

Mel
  • 51
  • 1
  • 4

2 Answers2

1

Try

Shell("cscript ""c:\VTS\QUEEN ANNES REVENGE\SYSTEM\VBS\UNDO_2.vbs""",1)

If your VBS needs complete command shell environment, use this:

Shell("cmd /c cscript ""c:\VTS\QUEEN ANNES REVENGE\SYSTEM\VBS\UNDO_2.vbs""",1)

and if your program should wait until the VBS ends, read this post:

VBA Shell and Wait with Exit Code

Community
  • 1
  • 1
Doc Brown
  • 19,739
  • 7
  • 52
  • 88
0

try This:

Set ws=CreateObject("Wscript.shell")
set ws.exec("ping " & ip & " -n 20")
set ws=nothing
Aminadav Glickshtein
  • 23,232
  • 12
  • 77
  • 117