The big problem I have is invoking a user-defined class method from an .onaction assignment in a control.

bigt95nt

New Member
Joined
Apr 11, 2011
Messages
26
:confused:The big problem I have is invoking a user-defined class method from an .onaction assignment in a control. I researched this in various resources’, but no luck. The following code executes fine, but when the button is pressed you get the following error

"Cannot run the macro “Pinger_57(7).xlsm.’ms.msg’. The macro may not be available in this workbook or all macros may be disabled"
Im sure that it is a syntax error ,but i cannot find the answer from the usual resources.
'CLASS
Private Name As String
Property Let IniDataScape(cName As String)
Name = cName
ActiveSheet.Buttons.Add(768, 312.6, 94.8, 31.2).Select
Selection.OnAction = "me.msg"
End Property

Public Sub msg()
MsgBox (Name)
End Sub
'END CLASS
Sub testObject()
Dim myDataScape As New DataScape
myDataScape.IniDataScape = "One"
End Sub
Sub testObject2()
Dim myDataScape As New DataScape
myDataScape.IniDataScape = "Two"
myDataScape.msg
End Sub

Thanks,
Anthony
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

Forum statistics

Threads
1,224,521
Messages
6,179,289
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top