INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

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

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

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

(OP)
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)) 

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)) 

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)) 

Also tried:

CODE --> VBA

Shell "net view>" & Chr(34) & "C:\temp\netview.txt" & Chr(34) 

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

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

Shell "cmd /c net view>" & """C:\temp\netview.txt""", vbHide

combo

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

(OP)
Thank you SO much!

"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57

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

(OP)
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:
http://ss64.com/nt/cmd.html

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close