Can I get the results of a Shell command launched in VBA

%3CLINGO-SUB%20id%3D%22lingo-sub-2383182%22%20slang%3D%22en-US%22%3ECan%20I%20get%20the%20results%20of%20a%20Shell%20command%20launched%20in%20VBA%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2383182%22%20slang%3D%22en-US%22%3E%3CP%3EHello%2C%3C%2FP%3E%3CP%3EI%20have%20a%20command%20line%20constructed%20in%20VBA%20which%20I%20send%20to%20the%20Shell%20command.%3C%2FP%3E%3CP%3EThe%20command%20outputs%20its%20results%20to%20StdOut.%3C%2FP%3E%3CP%3EIs%20there%20anyway%20of%20accessing%20this%20StdOut%20results%20as%20a%20string%20back%20in%20my%20VBA%20after%20the%20Shell%20command%20completes%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20know%20I%20could%20construct%20the%20command%20line%20to%20redirect%20the%20results%20to%20a%20file%20and%20read%20the%20file%20but%20I%20was%20hoping%20that%20there%20was%20a%20smarter%20way%20of%20getting%20the%20results.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20doing%20this%20in%20Excel%202010%20on%20Windows%2010.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20You%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2383182%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2383879%22%20slang%3D%22en-US%22%3ERe%3A%20Can%20I%20get%20the%20results%20of%20a%20Shell%20command%20launched%20in%20VBA%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2383879%22%20slang%3D%22en-US%22%3EWhat%20is%20your%20shell%20command%20trying%20to%20achieve%20exactly%3F%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2386252%22%20slang%3D%22en-US%22%3ERe%3A%20Can%20I%20get%20the%20results%20of%20a%20Shell%20command%20launched%20in%20VBA%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2386252%22%20slang%3D%22en-US%22%3EPerhaps%20this%20page%20helps%3F%20%3CA%20href%3D%22https%3A%2F%2Fwww.excelforum.com%2Fexcel-programming-vba-macros%2F1062779-retrieve-date-picture-taken-property-from-a-file-using-vba-in-excel.html%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.excelforum.com%2Fexcel-programming-vba-macros%2F1062779-retrieve-date-picture-taken-property-from-a-file-using-vba-in-excel.html%3C%2FA%3E%3C%2FLINGO-BODY%3E
Contributor

Hello,

I have a command line constructed in VBA which I send to the Shell command.

The command outputs its results to StdOut.

Is there anyway of accessing this StdOut results as a string back in my VBA after the Shell command completes?

 

I know I could construct the command line to redirect the results to a file and read the file but I was hoping that there was a smarter way of getting the results.

 

I am doing this in Excel 2010 on Windows 10.

 

Thank You

5 Replies
What is your shell command trying to achieve exactly?
Hello,
Thank you for taking the time to answer.
I have a list of media files in Excel. I want to pass these (one at a time) to a CLI version of a tool called MediaInfo. This tool outputs various details about the media in a single comma separated string. I want to parse this string to extract the details I want and to populate various cells next to the file list.
I will try this but I suspect it will only return standard file properties.
Details I'm after probably won't be there such as multiple sub-titles in a single file can each contain a Title, differing formats, language settings, etc. Other tracks in the file can also have differing codecs etc. All of which the MediaInfo tool will return for me.
Perhaps I will be wrong and it will work
OK I have tried this but it doesn't return the type of information I am after.