Sendkeys Statement vs Method ?

msleger

New Member
Joined
Sep 26, 2007
Messages
45
There is a SendKeys statement in VBA, and also an Application.SendKeys method. They both seem to do the same thing. Does anybody know of any differences between the two? Curious why the redundancy exists...
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
I can't seem to find any difference between the two - they seem to behave interchangeably in a few tests but I haven't subject it to much testing either. -- Alex
 
Upvote 0
The SendKey Statement sends the command to the Active Window!

The SendKeys Method sends the commands to the Active Application, which may be different than the active window!

But, they work the same and in most situations they are interchangable, the difference is when you are controling one application from another, rather that working within one application.

They are not "Redundant" and they do have different uses!
 
Upvote 0
Also remember that if your using Sendkeys that you cannot step in the VBA editor or you will send the sendkeys to the VBA editor instead of the intended application.
Below is an example I used for Internet explorer. It sends a Alt+Y.

Code:
AppActivate IEDoc
SendKeys "%Y"
 
Upvote 0

Forum statistics

Threads
1,213,536
Messages
6,114,202
Members
448,554
Latest member
Gleisner2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top