Solved

Using VBA variables in MS DOS

Posted on 2009-05-10
3
707 Views
Last Modified: 2012-05-06
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.

thanks
0
Comment
Question by:mk09
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 96

Accepted Solution

by:
Lee W, MVP earned 225 total points
ID: 24351481
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.
0
 
LVL 10

Expert Comment

by:3_S
ID: 24358944
I would also go for the batch file. you can redirect the output to a file with > to capture the return commands
example
cmd.exe program.bat > output.txt
0
 

Author Comment

by:mk09
ID: 24359625
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.

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question