Excel DDE macro: read a block of words
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 block of five words:Sub Block_Read()
'open dde link: testsol=DDE Topic |
RSIchan = DDEInitiate("RSLinx", "testsol") |
'get data and store in data variable |
data = DDERequest(RSIchan, "N7:30,L5,C1") |
'Paste data into selected range |
Range("[RSLINXXL.XLS]DDE_Sheet!A7:A11").Value = data |
'close dde link |
DDETerminate (RSIchan) |
End Sub
Provide Feedback