Read and update values from Excel or similar

You can link to any data item in the address map using DDE.

The details are:

  • Server: “WinModbus Master”
  • Topic: "Master"
  • Data: the address of the data in the data map, padded to 5 digits, e.g. “00001”

So, for instance, in an Excel cell, you could get an updating value of register 10001 by inserting something like:

='WinModbus Master'|'Master'!’10001’

You can't do a DDE write directly within Excel but you can do it using the built in VB script.

If you wanted to update a fixed address 10001 with a value from cell “A1” in Excel, you could do it with the following bit of VB: 

Dim nDDEChannel As Long
nDDEChannel = DDEInitiate("WinModbus Master", "Master")

If nDDEChannel = 0 Then
  MsgBox "Sorry, failed to open a DDE channel"
  DDEPoke nDDEChannel, "10001", Sheets(1).Range("A1")
DDETerminate (nDDEChannel)  
End If