Excel DDE macro: read a word

Reading data from a PLC via DDE requires a macro like the following. This macro assumes that there is a worksheet created and saved as
RSLINXXL.XLS
. This is the destination of the data that will be read by the macro. This routine reads a word:
Sub Word_Read()
'open dde link: testsol=DDE Topic
RSIchan = DDEInitiate("RSLinx", "testsol")
'get data and store in data variable
data = DDERequest(RSIchan, "N7:30")
'Paste data into selected range
Range("[RSLINXXL.XLS]DDE_Sheet!C7").Value = data
'close dde link
DDETerminate (RSIchan)
End Sub
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.
Normal