Application.Sendkeys WAIT parameter throws error

Anonymous
2019-11-25T15:40:17+00:00

Hi.  Having an issue with VBA Application.SendKeys on Excel for Mac.

MS documentation says the optional Wait parameter takes "True" or "False", but when I try to use it, the VBE throws a mysterious (i.e., blank) compile error.  Screengrab attached below.

Is this a known bug, or am I doing something wrong? The documentation is pretty straight forward....

Thanks in advance for your help.

Related:

Excel 2019 v16.29.1 on MacOS Mojave 10.14.6

Macbook Pro Retina (Late 2013)

----Edit----

FWIW, the SendKeys statement alone is rejected as invalid.  Screengrab follows:

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Jim G 134K Reputation points MVP Volunteer Moderator
    2019-11-25T16:05:00+00:00

    SendKeys uses a Windows API. Since Apple's Macintosh operating system is not Microsoft Windows, this particular command is limited to the Microsoft Windows operating system environment.

    Are you able to get SendKeys to work without the WAIT parameter? If yes, it would surprise me.

    0 comments No comments
  2. Anonymous
    2019-11-25T16:37:26+00:00

    Thanks for your quick reply, Jim.

    I'd been hoping MS had tamed this when moving to the single, shared codebase.  

    At minimum, the documentation could be clearer. The first sentence of the Application.SendKeys page reads, "Sends keystrokes to the active application." If they mean "Windows application", why not be specific?

    Even more head scratching is the documentation for the SendKeys statement, which actually says it's designed to work with MacOS applications:  "You can't use SendKeys to send keystrokes to an application that is not designed to run in Microsoft Windows or Macintosh."


    All of this is frustrating, since I'm just trying to build a workaround for a different Excel for Mac problem, where it intermittently borks formatting during xlPasteSpecial. (The code works fine in Windows.) I've contacted MS support directly, but so far no joy....

    I've found that simply double-clicking in a cell and then hitting Enter before invoking the xlPasteSpecial VBA reliably avoids the error, and am trying to build a routine to do that whenever the worksheet in question is activated on a Mac.

    0 comments No comments