ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   application.onkey doesn't work (https://www.excelbanter.com/excel-programming/297766-application-onkey-doesnt-work.html)

bob

application.onkey doesn't work
 
Hi,

I made a commandbutton (activeX) with following code:

Private Sub CommandButton1_Click()
Application.OnKey "{F8}", "test"
End Sub

Sub test()
MsgBox ("ok")
End Sub

But after clicking on it and pressing F8, nothing happens.
Thanks for any advice.
bob



Jan Karel Pieterse

application.onkey doesn't work
 
Hi Bob,

I made a commandbutton (activeX) with following code:

Private Sub CommandButton1_Click()
Application.OnKey "{F8}", "test"
End Sub

Sub test()
MsgBox ("ok")
End Sub

But after clicking on it and pressing F8, nothing happens.
Thanks for any advice.


Place the macro called "test" in a normal module.

Regards,

Jan Karel Pieterse
Excel MVP
www.jkp-ads.com


Melanie Breden

application.onkey doesn't work
 
Hi bob,

bob wrote:
I made a commandbutton (activeX) with following code:

Private Sub CommandButton1_Click()
Application.OnKey "{F8}", "test"
End Sub

Sub test()
MsgBox ("ok")
End Sub

But after clicking on it and pressing F8, nothing happens.
Thanks for any advice.
bob


write the Sub procedure in a standard module not in the Class module of the sheet.

--
Regards
Melanie Breden
- Microsoft MVP für Excel -

http://excel.codebooks.de (Das Excel-VBA Codebook)



All times are GMT +1. The time now is 08:54 AM.

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