Return Information from Shell Command
Hi Gareth - Thanks for the solution but I am having some problems.
Can you try and see if you can get it to work using "Dir C:\test.txt" as I
am having problems getting shell commands to write to a file.
All I need to know is how to get the bit working that actually creates the
file.
Ta
Andi
"Gareth" wrote in message
...
There might well be a more elegant solution (and indeed this might not
work) but you could try using "" to output the returned data to a file
rather than the screen. e.g.
Function fcnGetConfigLocation() as string
DIm var as long
Dim myPath as string
DIm F as integer
Var = Shell("Getconfig c:\temp.txt")
'assuming file just contains one path
F= Freefile
open "c:\temp.txt" for input as #F
input #F, mypath
close #F
kill "c:\temp.txt"
'check path exists
myPath = trim(mypath)
if dir(mypath) < "" then _
fcnGetConfigLocation = myPath
End Function
HTH,
Gareth
Andibevan wrote:
Hi All,
I have a dos command that lists the location of a config file associated
with a program.
This works fine from a dos prompt but can I use the Shell command in
such a
way that the location of the config file can be returned into VBA?
Something like Var = Shell("Getconfig") (I am aware that doing this
merely
would set Var = process thread associated with shell)
Thanks
Andi
|