View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default Error 5 on Shell Command

You might be right... I don't really remember. However, I'm not sure whether
the Windows operating system always has to be installed to a directory named
Windows or whether the user can modify the install directory. If the user
can modify it, your hard coded command processor path would also fail. Also,
will future Windows operating systems always use cmd.exe as the command
processor? Or, will 64-bit Windows operating systems use System32 to store
the command processor? I still think it is best to let VB obtain the command
processor and its path rather than hard coding it in.

--
Rick (MVP - Excel)


"joel" wrote in message
...
Rick: I believe windows 3.1 used "command.com". Starting in Win95 there
was
cmd.exe

"Rick Rothstein" wrote:

It might be better to let VB select the user's command processor rather
than
hard coding it (not all past versions of Windows used cmd.exe)...

Shell Environ("COMSPEC") & " " & strDirectoryList & ".bat", vbHide

--
Rick (MVP - Excel)


"joel" wrote in message
...
the shell doesn't understand command line instructions or bat files.
you
have to use cnd.exe to execute the bat files.

Shell ("c:\windows\cmd.exe " & strDirectoryList & ".bat"), vbHide '',
vbMinimizedNoFocus


"ExcelMonkey" wrote:

I am getting an "Error 5 Invalid procedure call or argument" on the
following:

lStr_Dir = ThisWorkbook.Path
strDirectoryList = lStr_Dir & "\Directory"
Shell (strDirectoryList & ".bat"), vbHide '', vbMinimizedNoFocus

?strDirectoryList
\\CGAS114\Username\My Documents\The Folder\ExcelVBA\Directory

Is this due to the spaces in the path?

Thanks

EM