grvs
12-07-2008, 11:48 PM
Hi,
I have to create a custom menu, and some buttons on that custom menu.
when those buttons are pressed I have to call a sub with arguments. I could call the sub without arguments but having problems in calling the sub with arguments.
here is the code
Public Sub BuildCustomMenu()
Dim i, j, k as Integer
Dim ctrl1 As CommandBarControl
Dim btn1 As CommandBarControl
Set ctrl1 = Application.CommandBars("Chart").Controls.Add _
(Type:=msoControlPopup, Before:=1, Temporary:=True)
i = 2
j = 3
k = 4
Set btn1 = ctrl1.Controls.Add
btn1.Caption = "cap1"
btn1.tag = "tag1"
btn1.OnAction = "mergeBuckets( i, j, k)"
' if I define Sub mergeBuckets without arguments and write btn1.OnAction = "mergebuckets" it runs fine...
End Sub
Public Sub mergeBuckets(CDB, firstRowInCDB, version As Integer)
Debug.Print "cp1 " & Now()
End Sub
I have to create a custom menu, and some buttons on that custom menu.
when those buttons are pressed I have to call a sub with arguments. I could call the sub without arguments but having problems in calling the sub with arguments.
here is the code
Public Sub BuildCustomMenu()
Dim i, j, k as Integer
Dim ctrl1 As CommandBarControl
Dim btn1 As CommandBarControl
Set ctrl1 = Application.CommandBars("Chart").Controls.Add _
(Type:=msoControlPopup, Before:=1, Temporary:=True)
i = 2
j = 3
k = 4
Set btn1 = ctrl1.Controls.Add
btn1.Caption = "cap1"
btn1.tag = "tag1"
btn1.OnAction = "mergeBuckets( i, j, k)"
' if I define Sub mergeBuckets without arguments and write btn1.OnAction = "mergebuckets" it runs fine...
End Sub
Public Sub mergeBuckets(CDB, firstRowInCDB, version As Integer)
Debug.Print "cp1 " & Now()
End Sub