HuntWhenever
Member
I have recently installed RSLinx Single-Node and I'm writing an Excel macro to read some recipe data from some PLCs. The macro is pretty straight forward with one exception: I can't seem to get the DDE topic to terminate so I can read a different PLC (RSLinx Single Node only allows one topic at a time).
Here's my macro in a nutshell...
Private Function OpenRSLinx(Topic As String) As Long
On Error Resume Next
OpenRSLinx = DDEInitiate("RSLINX", Topic)
If Err.Number <> 0 Then
MsgBox "Error Connecting to Topic", vbExclamation
OpenRSLinx = 0
End If
End Function
Sub ReadClick()
Dim UsedTopic As String
UsedTopic = Cells(1, 1)
rslinx = OpenRSLinx(UsedTopic)
'Reading code goes here
DDETerminate rslinx
End Sub
This works for one PLC. When I change to a different PLC (different topic), I get an error because RSLinx Single Node cannot run more than one topic. When I look at the Active DDE/OPC Topic List in RSLinx, the first topic I ran is listed as Active. Also, when I bring up the DDE/OPC Topic Configuration menu in RSLinx, in the Topic List on the left hand side shows the topic I just ran with a lock symbol beside it. The only way I can run another topic is to shut down RSLinx, then run my macro again with the different topic name.
Am I missing something here? All the research I've done indicates that DDETerminate is all that should be needed.
Additional info:
- Windows 10 Pro
- Office Excel 365 version 2005
- RSLinx Classic Single-Node Revision 4.12.00 CPR 9 SR 11.0
Here's my macro in a nutshell...
Private Function OpenRSLinx(Topic As String) As Long
On Error Resume Next
OpenRSLinx = DDEInitiate("RSLINX", Topic)
If Err.Number <> 0 Then
MsgBox "Error Connecting to Topic", vbExclamation
OpenRSLinx = 0
End If
End Function
Sub ReadClick()
Dim UsedTopic As String
UsedTopic = Cells(1, 1)
rslinx = OpenRSLinx(UsedTopic)
'Reading code goes here
DDETerminate rslinx
End Sub
This works for one PLC. When I change to a different PLC (different topic), I get an error because RSLinx Single Node cannot run more than one topic. When I look at the Active DDE/OPC Topic List in RSLinx, the first topic I ran is listed as Active. Also, when I bring up the DDE/OPC Topic Configuration menu in RSLinx, in the Topic List on the left hand side shows the topic I just ran with a lock symbol beside it. The only way I can run another topic is to shut down RSLinx, then run my macro again with the different topic name.
Am I missing something here? All the research I've done indicates that DDETerminate is all that should be needed.
Additional info:
- Windows 10 Pro
- Office Excel 365 version 2005
- RSLinx Classic Single-Node Revision 4.12.00 CPR 9 SR 11.0