ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using flowchart in simulation (https://www.excelbanter.com/excel-programming/425690-using-flowchart-simulation.html)

Tomas Nikolarsen

Using flowchart in simulation
 
I want to create a simple simulator with a graphical user interface using
flowcharts. My main problem is that shape objects do not create events. Does
anyone have any suggestion how I can do this?

I´m planning to program in VBA. The program I want to write is inspired by
this screenshot:
http://www.freedownloadscenter.com/B...creenshot.html


Thanks for ideas!


Chip Pearson

Using flowchart in simulation
 
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
wrote:

I want to create a simple simulator with a graphical user interface using
flowcharts. My main problem is that shape objects do not create events. Does
anyone have any suggestion how I can do this?

I´m planning to program in VBA. The program I want to write is inspired by
this screenshot:
http://www.freedownloadscenter.com/B...creenshot.html


Thanks for ideas!


Chip Pearson

Using flowchart in simulation
 

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)


On Tue, 17 Mar 2009 12:41:14 -0500, Chip Pearson
wrote:

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
wrote:

I want to create a simple simulator with a graphical user interface using
flowcharts. My main problem is that shape objects do not create events. Does
anyone have any suggestion how I can do this?

I´m planning to program in VBA. The program I want to write is inspired by
this screenshot:
http://www.freedownloadscenter.com/B...creenshot.html


Thanks for ideas!


Tomas Nikolarsen[_2_]

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

"Chip Pearson" wrote:

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
wrote:

I want to create a simple simulator with a graphical user interface using
flowcharts. My main problem is that shape objects do not create events. Does
anyone have any suggestion how I can do this?

I´m planning to program in VBA. The program I want to write is inspired by
this screenshot:
http://www.freedownloadscenter.com/B...creenshot.html


Thanks for ideas!




All times are GMT +1. The time now is 01:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com