Reputation: 358
I have several "Buttons" that change dynamically with the content of the sheet. I just need to figure out 1 line of code to get it working properly (Line 3):
Public Sub ClearMacro(shapename As String)
On Error Resume Next
ActiveSheet.Shapes(shapename).OnAction = Nothing
End Sub
I want to completely remove the macro from the shape, but keep the shape. Anything I can do differently to make this work?
Upvotes: 0
Views: 2981
Reputation:
Use Set
and Nothing
on objects. OnAction accepts a string value, use .OnAction = "" instead.
Public Sub ClearMacro(shapename As String)
On Error Resume Next
ActiveSheet.Shapes(shapename).OnAction = ""
End Sub
Upvotes: 2