Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running Shell command from VBA (List items to text from Net View command) 1

Status
Not open for further replies.

kjv1611

New member
Jul 9, 2003
10,758
0
0
US
I can run this command on its own all day long, and it works without flaw:
Code:
net view>"C:\temp\netview.txt"

But when I try to run it via a VBA Shell command, I get nothing:
[CODE VBA]Shell("net view>" & Chr(34) & "C:\temp\netview.txt" & Chr(34))[/CODE]

I also tried adding retVal into this just adding to the same line:
[CODE VBA]retVal = Shell("net view>" & Chr(34) & "C:\temp\netview.txt" & Chr(34))[/CODE]

And that does not work. Though I would think the latter isn't really what I'm after.

Also tried:
[CODE VBA]Call Shell("net view>" & Chr(34) & "C:\temp\netview.txt" & Chr(34))[/CODE]

Also tried:
[CODE VBA]Shell "net view>" & Chr(34) & "C:\temp\netview.txt" & Chr(34)[/CODE]

It all runs with no errors, but I get no file?

What am I missing? What am I forgetting?

"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57
 
Shell "cmd /c net view>" & """C:\temp\netview.txt""", vbHide

combo
 
Thank you SO much!

"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57
 
For anyone who needs a reference as to more detail of how to make this work, here's one I came across that's pretty informative:

Also, I now realize why it required that. So when you run Shell, you're not running a dos prompt, but rather the "run" command, and things do not 100% work the same between the two.

Thanks again!

"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top