Solved

Using VBA variables in MS DOS

Posted on 2009-05-10
3
698 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
3 Comments
 
LVL 95

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

685 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