Sendkeys to external application not working

S

Shazbot79

I am trying to use vba to launch a file (external application) and
when it has launched press F9. My code below launches the file and it
is visible but it doesn't hit F9. When I look at my taskbar it is the
spreadsheet that looks like it is active rather than the external app.

Code:

Sub OpenDashboard()

Dim dReturnValue As Double
dReturnValue = Shell("C:\Program Files\PRISM Europe\Dashboard
\dashboard.exe G:\isosbsm\BST Service\Proactive Service Management
\Wincharts\LPAS Dashboard.dsh")
AppActivate dReturnValue
SendKeys "{F9}", True


End Sub




Does anyone have any ideas?
Thanks
 
D

davesfx

I am trying to use vba to launch a file (external application) and
when it has launched press F9. My code below launches the file and it
is visible but it doesn't hit F9. When  I look at my taskbar it is the
spreadsheet that looks like it is active rather than the external app.

Code:

Sub OpenDashboard()

    Dim dReturnValue As Double
    dReturnValue = Shell("C:\Program Files\PRISM Europe\Dashboard
\dashboard.exe G:\isosbsm\BST Service\Proactive Service Management
\Wincharts\LPAS Dashboard.dsh")
        AppActivate dReturnValue
        SendKeys "{F9}", True

End Sub

Does anyone have any ideas?
Thanks

I use Sendkeys to automate another program that processes tickets from
inside excel.

The steps I use is:

1. shell out application
2. Activate Workbook "thisworkbook.activate"
3. Activate Application -- the code I use is Appactivate "TRIPS" <--
"TRIPS" being what the Caption is for the Window. You dont have to
use the entire Caption, just the first part of which is unique to all
other windows.
4. I normally have the application wait a few seconds so that Excel
can flip over to the application: Application.Wait Now +
TimeValue("00:00:02")
5. Then you can use Sendkeys;
SendKeys cell.Offset(0, 3).Value
SendKeys "{TAB 2}", True

Or in your case SendKeys "{F9}", true

Let me know if this helps you out. I think your next direction would
be to simply your code. Shell out your app and see what the caption
is for the window. After you succesfully shell it out, then you can
work on sending keys. Remember that you must isolate Excel and your
App and then flip between the 2 (depending if your needing a response
to import back into excel or not).

Great Luck!

Dave
 

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