• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 723
  • Last Modified:

Using VBA variables in MS DOS

Hello,  I would like to take variables from a VBA form and insert them into a series of DOS commands.  For example,  the program would open a MS DOS window using

Call Shell("cmd.exe" & dosCmd, vbNormalFocus)

then I would like  text field1 from the form inserted into the MS DOS command line and a return command. This would be followed by  text field2 from the form inserted and a return command supplied.

This will go on until all the user supplied information from the form have been entered into MS DOS.  I am not sure how I can carry over these variables into MS DOS and how to execute the line.

1 Solution
Lee W, MVPTechnology and Business Process AdvisorCommented:
There's no easy way to do that.

I would suggest you use VBA to construct a batch file - then you can output the contents of fields - and then shell out to run the batch file.
I would also go for the batch file. you can redirect the output to a file with > to capture the return commands
cmd.exe program.bat > output.txt
mk09Author Commented:
Thanks for the input everyone.  I had a feeling I would be using a batch file for this (which implemented today).

Just wanted to see if anyone had success with carrying over the variables directly.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now