Reputation: 11
I've been trying to solve this error all morning and can't get a handle on it. It looks like Excel really just doesn't want me to set the OnAction property of this shape.
The shape is part of a group of other rectangles/text boxes.
The code works on a non-grouped shape.
Function Macro1()
MsgBox (ActiveSheet.Shapes("box").OnAction) 'Returns the current OnAction string, as expected.
ActiveSheet.Shapes("box").OnAction = "'WorksheetName'!Macro2" '1004 error occurs here
End Function
I've tried setting it to "Macro2" , Macro2 , saving it as a string prior to the OnAction line, and even just trying to set it to an empty string "". No dice.
Upvotes: 1
Views: 698
Reputation: 11
SOLVED. The group shape interferes with the individual shape properties. The following works to break the group, edit the shape, then regroup:
Function Macro1()
With ActiveSheet
.Shapes("Home").Ungroup
.Shapes("box").OnAction = "Macro2"
With .Shapes.Range("box").Regroup
.Name = "Home"
End With
End With
End Function
Upvotes: 0