PDA

View Full Version : Can I run an executable within my VBA?



RonMcK
07-16-2010, 07:28 PM
I run a process at work (an .exe) that extracts records from a database and creates a tab-separated text file of its records.

Then, I run my vba program which opens the text file, does text to columns, reads the worksheet and adds a GUID to any record it finds without one, saves it back as tab-delimited text.

Finally, I run the program again (with a different config file) and import the records, updating the database.

Is there a way that can do all of this from inside my VBA program?

I want to invoke the program from inside my VBA code, have my code wait until the exe completes, resume and run my GUID function, then, swap config files for the exe program, and invoke it one more time, pausing the VBA until the exe completes and then let the VBA wrap things up?

Many Thanks in Advance.

Simon Lloyd
07-17-2010, 01:01 AM
You can use the wait method to pause Excel'Pause vba for 15 seconds
Application.Wait now+timevalue("00:00:15") you can use this to open an .exe http://www.thecodecage.com/forumz/local_links.php?catid=2&linkid=21 and this to close http://www.thecodecage.com/forumz/local_links.php?catid=2&linkid=23