View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default Shell Function - Execute DOS Command

Thanks for the feedback

Afraid my original suggestion was a never going to be useful. Somehow I read
you wanted to print a file named "print cat.txt". Sorry if that lead you up
the wrong path!

But had that been the case, ie a space in the fullname, the extra quotes are
necessary with some usages of Shell.

Regards,
Peter T

"bill_morgan" wrote in message
...
Here is what worked (simple oversight on my part):

Sub printer2()
m = Shell("command.com cd\")
t = Shell("command.com /c print cat.txt")
End Sub

OR

Sub print_stuff()
FileSystem.ChDir "c:\"
t = Shell("command.com /c print cat.txt")
End Sub



"Peter T" wrote:

Would it work if you replaced the space in "print cat.txt" with say an
underscore. If so try embracing the string in the shell function with an
additional pair of quotes, perhaps chr(34) & "string" & chr(34)

Regards,
Peter T


"bill_morgan" wrote in message
...
Excel 2000 running in XP:

Having trouble getting consistent results from VBA Shell Function.

For example, this command appears to run okay, but doesn't print

cat.txt,
which is located in root directory. Is there something wrong with

syntax?
Thanks ....

ID = Shell("command.com /c print cat.txt")

bill morgan