![]() |
has anybody come across this before?
this is just an example i am using to point out, i am trying to open command prompt, and run something in it from vba. Private Sub cmd1_Click() Dim OldPath As String Dim NewPath As String a = 13048 b = " VQRUN" & " " & a & ".prn" & " " & a & ".out" 'vqrun is the name of the program that i wanted to run in command prompt 'and 13048.prn and 13048.out are the parameters passed to the application vqrun. OldPath = CurDir NewPath = "C:\VQ80_2\ " ChDrive NewPath ChDir NewPath ', now, it opens the cmd prompt with the new path, which is fine(c:\vq80_2), but now i need to run 'vqrun along wit the parameters'. i know that the below line is wrong because i cannot simply add 'b', but is there anyway i could do this? ret = Shell("c:\winnt\system32\cmd.exe", b) anyhelp on this is much much appreciated because i have been waiting for the answer of this question for a long time. cheers. |
has anybody come across this before?
Jason,
Shell will actually run the program directly: ret = Shell(b) but note that b is a string, and it is possible that VQRUN requires double quote delimited string parameters as inputs, in which case you would need to insert " characters - done by inserting "" into your line like so: b = " VQRUN" & " """ & a & ".prn""" & " """ & a & ".out""" HTH, Bernie MS Excel MVP "Jason" wrote in message ... this is just an example i am using to point out, i am trying to open command prompt, and run something in it from vba. Private Sub cmd1_Click() Dim OldPath As String Dim NewPath As String a = 13048 b = " VQRUN" & " " & a & ".prn" & " " & a & ".out" 'vqrun is the name of the program that i wanted to run in command prompt 'and 13048.prn and 13048.out are the parameters passed to the application vqrun. OldPath = CurDir NewPath = "C:\VQ80_2\ " ChDrive NewPath ChDir NewPath ', now, it opens the cmd prompt with the new path, which is fine(c:\vq80_2), but now i need to run 'vqrun along wit the parameters'. i know that the below line is wrong because i cannot simply add 'b', but is there anyway i could do this? ret = Shell("c:\winnt\system32\cmd.exe", b) anyhelp on this is much much appreciated because i have been waiting for the answer of this question for a long time. cheers. |
has anybody come across this before?
Hello Bernie, sorry that i posted this in two places because i was a bit
desperate, sorry about that. anyway, i did try shell directly after what you said, but :( Dim OldPath As String Dim NewPath As String a = 13048 b = "C:\VQ80_2\VQ80RUN" & " """ & a & ".prn""" & " """ & a & ".out""" ret = Shell(b) it comes up with an error message stating file not found, but i have checked the file path, dont know why its not working. if i was to type it in by myself in dos, it would be like, c:\VQ80_2\VQ80RUN 13038.prn 13048.out, i am sure that b equals that other than the double quotations you mentioned, about the file not found, the 13048.prn is the input file, which is under c:\vq80_2, and the 13048.out is the file the program is supposed to produce in the same folder. |
has anybody come across this before?
another thing, i was just playing with shell, and i found out that its nothing wrong with the string b, but even just the program without the input parameters wont run, still comes up with a message file not found. b = "C:\vq80_2vq80run" ret = Shell(b) :( |
has anybody come across this before?
sorry, i did find out why it dint work, dnt bother replying, thank you very
much for your help, it was so simple at the end..:) |
has anybody come across this before?
Jason,
Since the folder is C:\VQ80_2\ Have you tried: b = "C:\vq80_2\vq80run" ret = Shell(b) Also, have you tried: ret = Shell("c:\VQ80_2\VQ80RUN 13038.prn 13048.out") HTH, Bernie MS Excel MVP "Jason" wrote in message ... another thing, i was just playing with shell, and i found out that its nothing wrong with the string b, but even just the program without the input parameters wont run, still comes up with a message file not found. b = "C:\vq80_2vq80run" ret = Shell(b) :( |
has anybody come across this before?
Jason,
Come on - you can't leave us hanging.... what was the simple solution? Bernie MS Excel MVP "Jason" wrote in message ... sorry, i did find out why it dint work, dnt bother replying, thank you very much for your help, it was so simple at the end..:) |
has anybody come across this before?
You have another response at your earlier thread.
Jason wrote: this is just an example i am using to point out, i am trying to open command prompt, and run something in it from vba. Private Sub cmd1_Click() Dim OldPath As String Dim NewPath As String a = 13048 b = " VQRUN" & " " & a & ".prn" & " " & a & ".out" 'vqrun is the name of the program that i wanted to run in command prompt 'and 13048.prn and 13048.out are the parameters passed to the application vqrun. OldPath = CurDir NewPath = "C:\VQ80_2\ " ChDrive NewPath ChDir NewPath ', now, it opens the cmd prompt with the new path, which is fine(c:\vq80_2), but now i need to run 'vqrun along wit the parameters'. i know that the below line is wrong because i cannot simply add 'b', but is there anyway i could do this? ret = Shell("c:\winnt\system32\cmd.exe", b) anyhelp on this is much much appreciated because i have been waiting for the answer of this question for a long time. cheers. -- Dave Peterson |
has anybody come across this before?
sorry bernie, the simple solution is your solution. i had no idea why it did
not work for sometime, i was playing with it for a while, and it worked!, :), thanks Bernie, and Dave. "Bernie Deitrick" wrote: Jason, Come on - you can't leave us hanging.... what was the simple solution? Bernie MS Excel MVP "Jason" wrote in message ... sorry, i did find out why it dint work, dnt bother replying, thank you very much for your help, it was so simple at the end..:) |
All times are GMT +1. The time now is 01:39 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com