PDA

View Full Version : [SOLVED] Assign Shape Macros - From List



dj44
01-01-2017, 10:42 AM
Hi folks,
:) Happy new 2017 to all.


I am trying to assign some macros to my shapes.



Shape Name

Macro



Shape1

Test1



Shape2

Test2



Shape3

test3








Sub ShapeMacros()





Dim ws As Worksheet
Dim i As Integer
Dim oShp As Shape

Set ws = Worksheets("Shapes")

For i = 3 To ws.Cells(ws.Rows.Count, "B").End(xlUp).Row
Set oShp = ws.Shapes(ws.Cells(i, "A").Name).Value
oShp.OnAction = ws.Cells(i, "B").Value2
Next i

End Sub






I cant seem to understand why there is an error, it should work

Please point me to where the syntax is wrong
thank you

mike7952
01-01-2017, 11:13 AM
Add the workbook name where the macro is


Sub ShapeMacros()
Dim ws As Worksheet
Dim i As Integer
Dim oShp As Shape

Set ws = Worksheets("Shapes")
For i = 3 To ws.Cells(ws.Rows.Count, "B").End(xlUp).Row
Set oShp = ws.Shapes(ws.Cells(i, "A").Value)
oShp.OnAction = "'" & ActiveWorkbook.Name & "'!" & ws.Cells(i, "b").Value
Next i
End Sub

dj44
01-01-2017, 11:38 AM
Thank you Mike,

Some times the little things really trip me up,but its all solved now

cheers

happy new year all

:)