selhamawy
asked on
Invoking shell from vb and usnig the output
I am trying to run a program in vb and use the output in the vb program. for example I am trying to do something like the following.
Dim x as String
x = Shell ("echo hello")
However i am getting a double returned when I want the string hello.
This is the original code. It is giving me an error that the file cannot be found. It stops at the place where it opens the new file.
ChDir "Y:\essbase\bin\"
tempName = "java Login " & server & " " & user & " >Y:\essbase\templates\temp .txt"
Sheets(ParamSheetName).Ran ge("IV6553 6").Value = tempName
Shell tempName
Workbooks.Open FileName:="Y:\essbase\temp lates\temp .txt"
Workbooks("mr1.xls").Range ("IV65536" ).Value = Workbooks("temp").Range("A 1").Value
Thanks.
Dim x as String
x = Shell ("echo hello")
However i am getting a double returned when I want the string hello.
This is the original code. It is giving me an error that the file cannot be found. It stops at the place where it opens the new file.
ChDir "Y:\essbase\bin\"
tempName = "java Login " & server & " " & user & " >Y:\essbase\templates\temp
Sheets(ParamSheetName).Ran
Shell tempName
Workbooks.Open FileName:="Y:\essbase\temp
Workbooks("mr1.xls").Range
Thanks.
see this link:
http://www.vb2themax.com/HtmlDoc.asp?Table=Articles&ID=40
http://www.vb2themax.com/HtmlDoc.asp?Table=Articles&ID=40
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
:)))
>DO NOT accept this comment as an answer.
Dan, are you in the top 20 yet? LOL
Dan, are you in the top 20 yet? LOL
I've got a ways to go. All of my VB points are due to this sort of mistake. I now have 3963 VB points...
When I'm done with the clean up I vow to give them to charity. In the meantime, I drop the VB Good Answer emails into a folder so I can list them as a group in the cleanup TA.
-- Dan
When I'm done with the clean up I vow to give them to charity. In the meantime, I drop the VB Good Answer emails into a folder so I can list them as a group in the cleanup TA.
-- Dan
>I now have 3963 VB
Soon this account will be eligible for EE-Pro! ;)
Soon this account will be eligible for EE-Pro! ;)
Incorrect comment accepted as answer. Per DanRollins' recommendation:
Richie_Simonetti: points for you at https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20328904
rspahitz: points for you at https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20328905
Netminder
CS Moderator
Richie_Simonetti: points for you at https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20328904
rspahitz: points for you at https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20328905
Netminder
CS Moderator
What you want is something like this:
x = shell("Echo hello > output.txt")
open "output.txt" for input as #1
line input #1, TextInfo$
close 1
msgbox TextInfo$