PDA

View Full Version : Solved: Shapes OnAction



mferrisi
01-18-2008, 12:48 PM
I created some shapes so that OnAction, a macro is run.


For x = 1 to 3
wt.Shapes.AddTextbox(msoTextOrientationHorizontal, ColWidth + 5, z* 11.25, 11.25, 11.25).Name = "tb1" & x
wt.Shapes("tb1" & x).OnAction = "TestMacro"
Next x


Sub TestMacro(????)
ShapeText = Shapes(w).TextFrame.Characters.Text
'or other similar things




Is there a way to pass to the subroutine which shape was clicked to activate the macro, similar to the BeforeDoubleClick below?

Thank you very much,

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim x As Integer
Dim y As Integer

y = Target.Column
x = Target.row
'etc etc

Andy Pope
01-18-2008, 01:12 PM
Use the Application.Caller information.


Sub TestMacro()
With ActiveSheet.Shapes(Application.Caller)
MsgBox .TextFrame.Characters.Text, vbInformation, .Name
End With
End Sub

mferrisi
01-18-2008, 01:52 PM
Thank you very much!