View Single Post
  #3  
Old April 13th 18, 03:56 PM posted to microsoft.public.windowsxp.general
JJ[_11_]
external usenet poster
 
Posts: 744
Default Cannot get Shell to work

On Thu, 12 Apr 2018 19:28:21 -0700, Robert Baer wrote:
Full program as-is below. Excel 2010.
Shell refuses to work (PC not MAC), always get error "File not found"
no matter how i mangle that line.

Naturally, there is NO "help" as this is M$ we are talking about.

Sub TestDIR()

' Macro recorded 04/12/2018 by ROBERT BAER
'
destPath = "G:\ANALOG"
DaTm = Date$ + " " + Time$
Open pPath + "Log.TXT" For Append As #1
' error "File not found" any variant of Shell.
pState = Shell("DIR *.* LOOK.DIR", vbNormalFocus)
'QB3 FORMAT is SHELL "DIR *.BMP LOOK.DIR"
Stop
Print #1, DaTm + " to " + vNam
Close

End Sub

Help?
Thanks.


The description of the Shell() function says:
"Runs an executable program and returns ..."

Meaning that, the function's first argument should be an executable program.
i.e. an executable file. DIR is an internal command of the Command Prompt
program, which is CMD.EXE.

So, in order to issue CMD internal command(s), use the /C switch of CMD.EXE.
e.g.:

CMD.EXE /C DIR *.* LOOK.DIR
Ads