
This sends a key combination of Ctrl + Shift + F2 to Excel, Still press the Ctrl + Shift keys when the macro runs the SendKeys The problem occurs because this is a very short macro, and you are In this example, the shortcut Ctrl + Shift + C has been assignedĪfter creating the shortcut, if you press Ctrl + Shift + C, a blankĬomment is inserted in the cell, but the comment does not open forĮditing - the SendKeys method doesn't work. Using SendKeys in VB with Shortcut Key Assigned
Is acknowledged on the Microsoft website: Error The SendKeys method, the SendKeys method might not work. If you try to run a macro with a keyboard shortcut, and that macro uses SendKeys Not Working From Shortcut SendKeys Not Working From Shortcut If the SendKeys command isn't working correctly, one of these solutions Then click on the macro name, and click Run.If a macro uses the SendKeys method, you can run that macro from and then press the Enter key, to select that command.then type E (to select the Edit command),.press Alt and typing I (to open the Insert menu),.In this example, SendKeys "%ie~" is like the manual shortcuts
SendKeys could simulate a keyboard shortcut to run a menu command. In Excel 2003, and earlier versions, where there is a Menu Bar, the
In the screen shot below, on the Review tab of the Excel Ribbon, the Edit Comment tooltip shows the Shift+F2 shortcut. That manual shortcut would open the worksheet comment in the active cell, so it is ready for you to edit the comment. In this example, SendKeys "+" is like manually pressing the Shift key, To see those macros, press Alt+F11, top open the Visual Basic Editor (VBE).įor example, the following macro inserts aĬomment with no user name, and opens that comment so it is ready for VBA page, there are macros that use the SendKeys method to open There is a full list of the codes, in the KeysĪnd Key Combinations section, below SendKeys Examples Running the macro without waiting for the keys to be processed.įor the Keys argument, you can use keys or key combinations, such Use False (or omit this argument) if Excel should continue. Use True if Excel should wait for the keys to be processed. You want to send to the application, as text. The Keys argument is required, and is the key or keys that. The SendKeys method has two arguments: SendKeys(Keys, Wait) That you would manually input in the active window. You can use the SendKeys method in your Excel macros VBA code, to simulate keystrokes You can read more about SendKeys on the Microsoft website: SendKeys Problems, if the wrong window is active when the code runs. SendKeys Method if no other option is available, because it can cause The SendKeys method simulates keystrokes that you would manually More Excel VBA Tutorials SendKeys Warning