PDA

View Full Version : Solved: Reading a DOS variable



michelle
06-01-2005, 02:41 AM
Dear VBA users,



From Outlook VBA we are trying to get a DOS variable.

To set a DOS variable we use:



Shell "command.com /c set MyVar=123456", vbHide



How can we read back the information of MyVar?


Nice regards,

Michelle.:hi:

xld
06-01-2005, 05:12 AM
Dear VBA users,



From Outlook VBA we are trying to get a DOS variable.

To set a DOS variable we use:



Shell "command.com /c set MyVar=123456", vbHide



How can we read back the information of MyVar?


Nice regards,

Michelle.:hi:

Michelle,

Suggestion. Set an environment variable and then use

Environ("myVar")

michelle
06-01-2005, 05:38 AM
Hello Xld,

:friends:
Thanks a lot, the right function!!

Michelle.

Paleo
06-01-2005, 01:33 PM
You can use something like this also:


Dim objShell
Dim cmdLine As String
cmdLine = "echo Test"
Set objShell = CreateObject("WScript.Shell")
Set objExecObject = objShell.Exec("cmd /c " & cmdLine)
If Not objExecObject.StdOut.AtEndOfStream Then
Range("B2") = objExecObject.StdOut.ReadLine()
End If