ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   execute a .exe file and type a text string by vba on it (https://www.excelbanter.com/excel-programming/384562-execute-exe-file-type-text-string-vba.html)

Marco[_9_]

execute a .exe file and type a text string by vba on it
 
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


NickHK

execute a .exe file and type a text string by vba on it
 
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

"Marco" wrote in message
oups.com...
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





All times are GMT +1. The time now is 05:08 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com