Using flowchart in simulation

C

Chip Pearson

You can assign a macro to a Shape object so that the macro will be
executed when a shape is clicked. Within that macro,
Application.Caller will be a string containing the name of the shape
that was clicked. Therefore, you could assign the same macro to all
shapes, use Application.Caller to determine which was clicked, and
then take the appropriate action. E.g.,


Sub ShapeWasClicked()
Select Case Application.Caller
Case "Rectangle1"
' do something
Case "Oval3"
' do something else
'....
End Select
End Sub

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)


On Tue, 17 Mar 2009 08:41:07 -0700, Tomas Nikolarsen <Tomas
 
C

Chip Pearson

I should have added that if you need to provide additional information
unique to a shape, you can use the AlternativeText property to store
that info. Right-click the shape, choose Format Autoshape, then the
Web tab, and enter anything you want in the Alternative Text box. You
can then get that data with code like

Sub ShapeClick()
Dim SH As Shape
Set SH = Worksheets("Sheet1").Shapes(Application.Caller)
MsgBox "hello from " & SH.Name & vbCrLf & _
SH.AlternativeText
End Sub

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 
T

Tomas Nikolarsen

Thanks for your reply. I used the "OnAction" property of the shape and with
Application.Caller I can decide what shape beeing clicked.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top