Modbus poll OLE automation for 3 slaves

I already using modbus poll OLE automation and getting data from 1 device in excel using VBA but not able to get data from 3 devices. Please tell me how to get data from 3 modbus slaves devices by using Excel VBA.

Please tell me the VBA code for getting data in excel from 3 modbus slaves devices,
our first IP address is 10.62.11.41 & port is 14
second IP address is 10.62.11.42 & port is 20
third IP address is 10.62.11.43 & port is 22


Modbus Poll version - latest
Tested on Windows - Windows7 & 10
Below is the VBA excel code for 1 device-


Public doc1 As Object
Public app As Object
Dim res As Integer
Dim n As Integer

Private Sub StartModbusPoll_Click()
Set app = CreateObject("Mbpoll.Application")
Set doc1 = CreateObject("Mbpoll.Document")
' Read 10 Input Registers every 1000ms
res = doc1.ReadInputRegisters(1, 2047, 2, 1000)
' doc1.ShowWindow()
app.Connection = 3 ' Modbus RTU/ASCII Over TCP/IP
app.IPAddress = "10.62.11.41" ' local host
app.ServerPort = 14
app.ConnectTimeout = 1000
res = app.OpenConnection()
End Sub

Private Sub ReadB1_Click()

For n = 0 To 0
Cells(6, 2) = doc1.URegisters(n)
Next n
End Sub
 
Top