SendKeys Command and Active Window

M

Matt Waldron

While recording a macro I want to use the SendKeys
command to send keystrokes to MathType 5 which is my
equation editor in Microsoft Word 2002. How do I get
MathType 5 to be the active window so it will execute the
commands I am trying to send it. The commands are
ignored. My knowledge of VB is limited.
Matt Waldron
 
D

DA

Hi Matt

You can cycle through the task list to try and pick up
your application based on a search string(In the sample I
provided below, I'm picking up the Calculator before
sending a key combination).

Alternatively if you know your task name you can also
specify it directly (preferable to avoid hitting on other
tasks).

Anyway, you should get the idea from the following:

-------------
Sub SendKeyToApp()
For Each Task In Tasks
If InStr(Task.Name, "Calculator") > 0 Then
Task.Activate
SendKeys "1" & "{+}" & "1" & "=", True
End If
Next Task
End Sub
 
G

Guest

Thanks, that did the trick! Matt
-----Original Message-----
Hi Matt

You can cycle through the task list to try and pick up
your application based on a search string(In the sample I
provided below, I'm picking up the Calculator before
sending a key combination).

Alternatively if you know your task name you can also
specify it directly (preferable to avoid hitting on other
tasks).

Anyway, you should get the idea from the following:

-------------
Sub SendKeyToApp()
For Each Task In Tasks
If InStr(Task.Name, "Calculator") > 0 Then
Task.Activate
SendKeys "1" & "{+}" & "1" & "=", True
End If
Next Task
End Sub
--------------

Best of luck,
Dennis



.
 

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