Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old September 28th, 2016, 04:36 PM
Registered User
Join Date: Sep 2016
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default VBA Get cmd screen info from shell program

Access 2013

I have a program test.exe that when run in a command window displays to that window some information about a file.

below is what I see if I run test --info "c:\test\testfile.jpg" in the command window

C:\test>test --info "c:\test\testfile.jpg"
Info about testfile.jpg:
size: x=9.240 y=4.450 z=12.000
number of colors: 792
number of shells: 1
volume: 124.301

I have tried:

x = Shell("C:\test\test --info c:\test\testfile.jpg", 0)

MsgBox x

but each time I run it I get a different number and it's never any part of the display info.

How can I run this (DOS Command only program) and get the results in a VBA string variable?

BTW the program has no option to save the info to a file just displays it in the command window.
Old January 30th, 2017, 09:22 PM
Friend of Wrox
Join Date: Sep 2010
Posts: 245
Thanks: 5
Thanked 24 Times in 23 Posts

You should be able to redirect the output to file and the read it with VBA. I do this with several command line tools.

See: Using command redirection operators

1) Generate the output file:

Dim OutPutFile as String

OutputFile = "C:\Test\info.txt"

x = Shell("C:\test\test --info c:\test\testfile.jpg >  " & OutputFile, 0)
2) Read the file stored in the variable OutputFile

There are several ways to read in the contents of the Text file.

I like to use:

Line Input # Statement
You can find examples in the Help File for Access.
Boyd Trimmell aka HiTechCoach (.com)
Microsoft Access MVP Alumni 2010-2015

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Shell to invoke cmd script with argument srcLakeJake Access VBA 3 October 26th, 2007 09:35 AM
How do I copy info from 1 program to another? hard boiled VB How-To 1 June 12th, 2007 11:58 AM
how to call shell cmd to open exe on clientside? nana Javascript How-To 6 May 25th, 2006 03:23 AM
Log on Screen Info deler9 Javascript How-To 0 June 17th, 2005 08:19 AM
help with my program (displaying a pic on screen) bcmaverik C# 6 July 9th, 2004 05:23 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.