Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a program that I can presently only run using the command line window
(which used to be the MS-DOS window I guess). I would like to integrate this program with programs I've written in VBA. Is it possible to call "DOS" programs using VBA code? Help would be greatly appreciated. Cheers, Thomas |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Thomas,
See the Shell funciton and example in CVBA help --- Regards, Norman "Thomas Moen" wrote in message ... I have a program that I can presently only run using the command line window (which used to be the MS-DOS window I guess). I would like to integrate this program with programs I've written in VBA. Is it possible to call "DOS" programs using VBA code? Help would be greatly appreciated. Cheers, Thomas |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
One way is to put your DOS commands in a batch files and call this from Excel
Sub rundos() Call Shell("c:\test.bat", 1) End Sub Runs test.bat in the root of C Mike "Thomas Moen" wrote: I have a program that I can presently only run using the command line window (which used to be the MS-DOS window I guess). I would like to integrate this program with programs I've written in VBA. Is it possible to call "DOS" programs using VBA code? Help would be greatly appreciated. Cheers, Thomas |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I think the code you want is
Shell Environ("comspec") but read the help file first :) hth Keith |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sub runbat()
Call Shell(Environ$("COMSPEC") & " /c c:\mybat.bat", vbNormalFocus) End Sub |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am trying to use redirection and it does not work.
*********** ds = InputBox("Type in reporting date as YYYY-MM-DD", "reporting date") exestr = "Rterm --restore --save < m.in.R out.txt --args " & ds ret = Shell(exestr) ' opens Rterm and does not source the script ************* if I put the string in a batch file aaa.bat and use ret=Shell(aaa.bat) then redirection works, but I lose the return value from the process. ret simply reports whether cmd started successfully. I need to have the value returned from Rterm, which is 0 upon successful finish and -1 otherwise. Thank you all "teepee" wrote: Sub runbat() Call Shell(Environ$("COMSPEC") & " /c c:\mybat.bat", vbNormalFocus) End Sub |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Redirection, like non-built-in DOS function calls, need to call the command processor in order to work. Try this Shell statement instead and see if it works...
ret = Shell(Environ$("comspec") & " /c " & exestr) Rick "stephen" wrote in message ... I am trying to use redirection and it does not work. *********** ds = InputBox("Type in reporting date as YYYY-MM-DD", "reporting date") exestr = "Rterm --restore --save < m.in.R out.txt --args " & ds ret = Shell(exestr) ' opens Rterm and does not source the script ************* if I put the string in a batch file aaa.bat and use ret=Shell(aaa.bat) then redirection works, but I lose the return value from the process. ret simply reports whether cmd started successfully. I need to have the value returned from Rterm, which is 0 upon successful finish and -1 otherwise. Thank you all "teepee" wrote: Sub runbat() Call Shell(Environ$("COMSPEC") & " /c c:\mybat.bat", vbNormalFocus) End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Programs running slow | Excel Discussion (Misc queries) | |||
Running Macros from Command line | Excel Programming | |||
Running a macro from a command line | Excel Programming | |||
Running a macro from the command line | Excel Programming | |||
Running external programs | Excel Programming |