i have a excell application that i have aded a button into to pull in data from a db. i want to create another button to run several dos commads. how would i get vba to run these 30 comand lines on the button click.
use VB shell command. Open up a vb form and type in the word shell. Highlight the word and hit F1. This should bring you to the help page(if MS Visual Studio help page is installed).
often, if you have a bunch of DOS commands to execute, it is better to make a batch file and have the shell execute this. One thing that this lets you do is pipe the output to a file and then you can read that file back into vb and display it.
Extra Note on using the shell command is after executing the shell command VB continues to execute statements so doesn't wait to see if the shell process finished or not.
If you need to wait for the process to finish then two options are to have a do loop which just keeps looping until a condition is met, creation of a file for example.
The other method is to use API calls, these are noted in the API forum somewhere can't remember of the top of my head what the calls are. Be aware though that different platforms dont all have the same API calls.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.