ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How can i Create (https://www.excelbanter.com/excel-programming/306490-how-can-i-create.html)

Norton

How can i Create
 
Hi all,


I would like to add some menu Item based on the following code but it
returns failed. The reason is that i pass an parameter on "OnAction" which
excel file cannot find the macroname RunTest(1)

Here is my code
==========================================
MenuBars(xlWorksheet).Menus(menuName).MenuItems.Ad d Caption:=itemName,
OnAction:=RunTest(1)



Public Sub RunTest(ByVal iParameter as integer)
Msgbox(iParameter)
End Sub
===================================

What can i do?


Regards,
Norotn



Soo Cheon Jheong[_2_]

How can i Create
 
Hi,

.OnAction:= "RunTest(1)"

--
Regards,
Soo Cheon Jheong

"Norton" wrote in message
...
Hi all,


I would like to add some menu Item based on the following code but it
returns failed. The reason is that i pass an parameter on "OnAction" which
excel file cannot find the macroname RunTest(1)

Here is my code
==========================================
MenuBars(xlWorksheet).Menus(menuName).MenuItems.Ad d Caption:=itemName,
OnAction:=RunTest(1)



Public Sub RunTest(ByVal iParameter as integer)
Msgbox(iParameter)
End Sub
===================================

What can i do?


Regards,
Norotn





papou[_7_]

How can i Create
 
Hello Norton
Since your macro takes a parameter, OnAction will not accept it as it is.
So provided Runtest will always take 1 on its parameter for the Onaction
method,I would suggest you create another macro to run your Runtest macro
and use this new macro name instead.

HTH
Cordially
Pascal

"Norton" a écrit dans le message de
...
Hi all,


I would like to add some menu Item based on the following code but it
returns failed. The reason is that i pass an parameter on "OnAction" which
excel file cannot find the macroname RunTest(1)

Here is my code
==========================================
MenuBars(xlWorksheet).Menus(menuName).MenuItems.Ad d Caption:=itemName,
OnAction:=RunTest(1)



Public Sub RunTest(ByVal iParameter as integer)
Msgbox(iParameter)
End Sub
===================================

What can i do?


Regards,
Norotn





Norton

How can i Create
 
Thx for your advise!


"Norton" wrote in message
...
Hi all,


I would like to add some menu Item based on the following code but it
returns failed. The reason is that i pass an parameter on "OnAction" which
excel file cannot find the macroname RunTest(1)

Here is my code
==========================================
MenuBars(xlWorksheet).Menus(menuName).MenuItems.Ad d Caption:=itemName,
OnAction:=RunTest(1)



Public Sub RunTest(ByVal iParameter as integer)
Msgbox(iParameter)
End Sub
===================================

What can i do?


Regards,
Norotn






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

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