Shell to another program from Excel

J

Jimbo

I am trying to shell to an Image viewing program from Excel by using the
following line of code:
Windows(1).WindowState = xlMinimized
ReturnValue = Shell(ImgViewer, 3)

Where ImgViewer is a string containg the path and filename of the program to
be executed.
Excel minimises but immediately returns to full screen
I have inserted a msgbox to trap the ReturnValue and it displays whilst
Excel is minimised but the image viewing program does not appear to be
running
On closing the msgbox Excel returns to normal

What have I done wrong ?

Ultimately I will want to append a variable to the ImageViewer string to
pass command line switches to the program e.g.
ReturnValue = Shell(ImgViewer &" " & Filename, 3)
Is this possible ?
 
A

Anthony D

Hi Jimbo,

Have done something along similar lines which may be adaptable (?)

RetValBmp = Shell(Directory & "img.bat", vbNormalFocus)

The directory is the path to the batch file (e.g. d:\myapp\) (where the xls
file and the image viewer i_view32.exe are also kept).
The batch file contains:
d:
cd d:\myapp\
i_view32.exe .\*.jpg /convert=.\*.bmp

It converts jpg image(s) in that directory to bmp.

Hope this (and/or further posts) may be of help

Anthony
 
J

Jimbo

Thanks for the input Anthony,
I'm not sure that I can use your method because the workbook will be used on
a number of different pcs with different image viewing programs.
With the assistance of others in this newsgroup I have managed to write the
code to identify the default image viewing program i.e. the file associated
with opening an image file. This is stored in the variable ImgViewer.
If I understand your approach correctly individual batch files would be
required and would need updating if/when different image viewing programs
were installed.
Nevertheless I thank you for your suggestion.

Regards
Jim Burton
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top