Description

WonderWare is a widely used Human Machine Interface (HMI) in manufacturing floor. However, it can be hard to debug due to its lag of debugging tools. The problem can be worse if programmer uses dynamic tag. On way to see tag values is using DDE in Excel. For dynamic tag, Excel VBA can be used to create dynamic DDE formula.

Sample Dynamic DDE Formula Application in Excel VBA

Sample code below creates dynamic formula to show tag values of a device. Each device has its own bar code. WonderWare reads device bar code and uses last three digits to construct dynamic tags for device location and device number.

This sample code can be used with a VBA self repeating timer to update tag formula in preset time.

Sample Code for Dynamic DDE formula in Excel VBA

Sub getWonderWareTagValues()
Dim txtFormula As String

txtFormula = “=VIEW|TAGNAME!DeviceBarCode_” & Right(CStr(Sheet1.Cells(2, 2).Value), 3)
Sheet1.Cells(5, 2).Formula = txtFormula     ‘Device Bar code

txtFormula = “=VIEW|TAGNAME!DeviceLocation_” & Right(CStr(Sheet1.Cells(2, 2).Value), 3)
Sheet1.Cells(6, 2).Formula = txtFormula     ‘Device Location

txtFormula = “=VIEW|TAGNAME!DeviceNumber_” & Right(CStr(Sheet1.Cells(2, 2).Value), 3)
Sheet1.Cells(7, 2).Formula = txtFormula     ‘Device Number

End Sub