Visual Basic for Applications (VBA) code sample
You can also perform a DDE read and write from a Visual Basic application to FactoryTalk Linx Gateway.
The following sample code reads the tag value.
Sub prRead() 'Initiate DDE FTLGW_DDE = DDEInitiate("FTLinxGatewayDDE", "ShortcutNameOrNsName") 'read tag value tagValue = DDERequest(FTLGW_DDE, "TagName") 'Terminate DDE DDETerminate FTLGW_DDE End Sub
The following sample code reads the array value.
Sub prReadArray() 'Initiate DDE FTLGW_DDE = DDEInitiate("FTLinxGatewayDDE", "ShortcutName") 'read array tag value (start with element 2, length = 10) - for folder with scalar data tagValues = DDERequest(FTLGW_DDE, "ArrayName[2],L10") 'Terminate DDE DDETerminate FTLGW_DDE End Sub
The following sample code writes the tag value.
Sub prWrite() 'Initiate DDE FTLGW_DDE = DDEInitiate("FTLinxGatewayDDE", "ShortcutNameOrNsName") 'write tag value from Range "A1" to Tag DDEPoke FTLGW_DDE, "TagName", Range("A1") 'Terminate DDE DDETerminate FTLGW_DDE End Sub
Provide Feedback