execute a .exe file and type a text string by vba on it

M

Marco

Hi all,

I have a software ending with .exe that i would like to open, type
the
word 'select' on it, press 'enter' and make it run from excel.


I used the following code but vba doesn't recognize 'wd' as an
application but as a number.


Dim wd As Application


wd = Shell("Y:\--\Sel.exe", 1)


Application.SendKeys "select"


Do you have any clues about?


Thanks,
Marco
 
N

NickHK

Marco,
Check the help for the Shell function.
You will see that it returns a Variant (Double), which is the PID.
In Excel VBA, "Application" will refer to Excel application, not just any
application.

Also, you can use vbNormalFocus in place of 1 for clarity.

Note that there are 2 versions of SendKeys:
Application.SendKeys
VBA.SendKeys

The first is Excel's, the second VBA's.
Whilst it may not matter in your case, I have read there are subtle
differences between the 2.

I assume you have checked that there is no better way of interacting with
this exe ?
Command line, DDE, automation ?

NickHK
 

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