Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
SHELL command
Greetings !
Regarding - Shell "dir C:\ /S C:\DirList1.$$$",1 ...which works just FINE in a DOS window, but not in VB [RunTime error 53: File not found] Can SKS please suggest - (a) why it doesn't work (b) what it should be, in order to work; and/or (c) a better way of achieving the same thing? RClay AT haswell DOT com |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
SHELL command
Robin,
Put the DOS Dir command in a bat file and call that bat file from Shell. E.g, Shell "C:\Test.bat",1 -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Robin Clay" wrote in message ... Greetings ! Regarding - Shell "dir C:\ /S C:\DirList1.$$$",1 ..which works just FINE in a DOS window, but not in VB [RunTime error 53: File not found] Can SKS please suggest - (a) why it doesn't work (b) what it should be, in order to work; and/or (c) a better way of achieving the same thing? RClay AT haswell DOT com |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
SHELL command
Hi Robin,
Chip's solution will work as always. I'd point out the reason your shell failed is that redirection requires invoking the command processor. Like this... Shell(Environ$("comspec") & " /c dir C:\ /S C:\DirList1.$$$",1) Spaces in the path or filename have to be wrapped in double quotes. Shell Environ("comspec") & " /k ping """ & strIP & """ """ & strFile & """", vbNormalFocus -- John johnf202 at hotmail dot com "Robin Clay" wrote in message ... Greetings ! Regarding - Shell "dir C:\ /S C:\DirList1.$$$",1 ..which works just FINE in a DOS window, but not in VB [RunTime error 53: File not found] Can SKS please suggest - (a) why it doesn't work (b) what it should be, in order to work; and/or (c) a better way of achieving the same thing? RClay AT haswell DOT com |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
SHELL command
Thank you both very much for your kind response to my plea
Put the DOS Dir command in a bat file and call that bat file from Shell. E.g, Shell "C:\Test.bat",1 Hmmm... I had thought of that, but thought there MUST be a better way ! Like this... Shell(Environ$("comspec") & " /c dir C:\ /S C:\DirList1.$$$",1) Spaces in the path or filename have to be wrapped in double quotes. Blimey, that's complicated ! I think I'll stick to Chip's method after all ! Thus :- Public Sub RunShell(myCommandLine, myWindowStyle) ' Write it to a batch file Open "C:\RunShell.bat" for Output as #1 Print #1, myCommandLine Close #1 ' Run the batch file Shell "C:\RunShell.bat", myWindowStyle ' Delete the batch file Kill "C:\RunShell.bat" End Sub So instead of Shell "dir C:\ /S C:\DirList1.$$$",1 I would use RunShell "dir C:\ /S C:\DirList1.$$$", WindowStyle Thanks again |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to use the "shell" command? | Excel Discussion (Misc queries) | |||
How can you wait for the SHELL command to terminate ? | Excel Programming | |||
Shell function II | Excel Programming | |||
Shell function | Excel Programming | |||
Copying a file with VBA (or with a SHELL command) | Excel Programming |