Using a macro to read values – Echelon OpenLNS Commissioning Tool User Manual

Page 209

Advertising
background image

OpenLNS CT User’s Guide

193

• If you are monitoring the lamp value, you can change the color of the Visio shape based on

the brightness of the lamp. To do this, enter the following function: Sheet.<Data Point
SmartShape ID index
>!User.MonValue/10.

4. Click the accept button (

) in the Formulas box.

Using a Macro to Read Values

To read from a Data Point SmartShape value using a Macro, follow these steps:

1. Click the Developer tab, and then click Macros. The Macros dialog box opens.

2. In the Macros Name: dialog box, enter a name for the Macro. Click Create. The Network

Passwords dialog opens if this is the first time you are creating a Macro or entering VBA code in
your OpenLNS CT drawing.

3. Enter enumerate in the Password box.

4. The Visio VBA editor opens.

5. In the right pane, enter VBA code for the Visio shape to read from a data point. The following

code is used to change the text in the Visio shape to “ON” and the color to yellow when the state
of the lamp is on (1). If the state of the lamp is off (0), the text in the Visio shape changes to
OFF” and the color changes to black.

Sub LED

Dim vsoPage As Visio.Page
Dim myShape As Shape
Dim myShape2 As Shape
Set myShape = ActivePage.Shapes("Circle")
Set myShape2 = ActivePage.Shapes("Data Point.50")

If myShape2.Cells("User.MonValue") = 1 Then

myShape.Cells("FillForegnd") = 5
myShape.Text = "ON"

Else

myShape.Cells("FillForegnd") = 0
myShape.Text = "OFF"

End If

End Sub

Advertising