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
 
M

mstrobel

I've used your example succussfully on many projects when I am just activating a new workbook/worksheet; however, I have really had problems when running an Excel macro from Access. In my case, I run the Excel macro using:

oXL.Run macroGetProjects

The macro loads just fine, but I cannot regain control in order to SendKeys (series of Tabs and Enters). I tried AppActivate "Search Projects" (the user form loaded in Excel by macroGetProjects). I've also tried putting the SendKeys statement prior to macro call. Nothing seems to work.

Any ideas?
 
M

mstrobel

davesfx

I've used your example succussfully on many projects when I am just activating a new workbook/worksheet; however, I have really had problems when running an Excel macro from Access. In my case, I run the Excel macro using:

oXL.Run macroGetProjects

The macro loads just fine, but I cannot regain control in order to SendKeys (series of Tabs and Enters). I tried AppActivate "Search Projects" (the user form loaded in Excel by macroGetProjects). I've also tried putting the SendKeys statement prior to the macro call. Nothing seems to work.

Any ideas?
 

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