Add reference "Windows Script Host Object Model" to VBA project, and then use below code:
Dim objShell As New WshShell
Dim objExec As WshExec
Set objExec = objShell.Exec(Command)
Dim objOutput As IWshRuntimeLibrary.TextStream
Set objOutput = objExec.StdOut
Dim strLine As String
While Not objOutput.AtEndOfStream
strLine = objOutput.ReadLine
Debug.Print strLine 'This will print return value
Wend
Comments
Post a Comment