View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Matt Matt is offline
external usenet poster
 
Posts: 516
Default SendKey Question

In case anyone is interested in the answer I figured it out. In microsoft
excel's help
on sendkeys you'll see the following code:

Dim ReturnValue, I
ReturnValue = Shell("CALC.EXE", 1) ' Run Calculator.
AppActivate ReturnValue ' Activate the Calculator.
For I = 1 To 100 ' Set up counting loop.
SendKeys I & "{+}", True ' Send keystrokes to Calculator
Next I ' to add each value of I.
SendKeys "=", True ' Get grand total.
SendKeys "%{F4}", True ' Send ALT+F4 to close Calculator

Make sure caculator is running, comment the second line "RetrunValue..." and
replace the third with AppActivate "Calculator".

Right in front of my face......!!!!!!!!!

"Matt" wrote:

Hi All,

I would like to send key strokes from excel to an application that is
already open (I don't want to open a new instance of it, as shown is Sendkey
example of the calculator). How do I get focus to the application?

Any help would be appreciated.
Thanks,
Matt