ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Simulating Key Presses in Macros (https://www.excelbanter.com/excel-programming/356756-simulating-key-presses-macros.html)

[email protected]

Simulating Key Presses in Macros
 
Hi,

How do I simulate pressing the keys using a macro in Excel. For
example, if I want to simulate pressing the keys Alt+H+A, what should I
do in the macro?

Thanks.


ward376

Simulating Key Presses in Macros
 
Try something like:

Private Sub CommandButton1_Click()
Application.SendKeys ("%ha")
End Sub

If you execute from the vb editor, you get the About box for Visual
Basic, but this brings up about for Excel.


Ivan F Moala[_75_]

Simulating Key Presses in Macros
 

If it is the About dialog you want to invoke then


Code
-------------------

Sub About()
Application.CommandBars.FindControl(ID:=927).Execu te
End Sub

-------------------

--
Ivan F Moal

-----------------------------------------------------------------------
Ivan F Moala's Profile: http://www.excelforum.com/member.php...nfo&userid=195
View this thread: http://www.excelforum.com/showthread.php?threadid=52511


ward376

Simulating Key Presses in Macros
 
Ivan! Sweet! Where do you look for the ID numbers?



All times are GMT +1. The time now is 01:58 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com