Results 1 to 4 of 4

Sendkeys Statement vs Method ?

This is a discussion on Sendkeys Statement vs Method ? within the Excel Questions forums, part of the Question Forums category; There is a SendKeys statement in VBA , and also an Application.SendKeys method. They both seem to do the same ...

  1. #1
    New Member
    Join Date
    Sep 2007
    Posts
    45

    Default Sendkeys Statement vs Method ?

    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...

  2. #2
    MrExcel MVP
    Moderator
    xenou's Avatar
    Join Date
    Mar 2007
    Location
    Clev. OH, USA
    Posts
    15,004

    Default Re: Sendkeys Statement vs Method ?

    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

    Using: Office 2007/Win7 (work) Office 2010/Win7 (home)

    You are rich in proportion to the number of things you can let alone.
    -- Henry David Thoreau

  3. #3
    MrExcel MVP Joe Was's Avatar
    Join Date
    Feb 2002
    Location
    Central Florida, USA
    Posts
    7,539

    Default Re: Sendkeys Statement vs Method ?

    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!
    JSW: Try and try again: "The way of the Coder!"

  4. #4
    New Member
    Join Date
    Nov 2008
    Posts
    11

    Default Re: Sendkeys Statement vs Method ?

    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"

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


DMCA.com