Posted 18 Jul 2020 (edited) 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 Edited 19 Jul 2020 by HuntWhenever typo Share this post Link to post Share on other sites
Posted 19 Jul 2020 (edited) @HuntWhenever, at first glance it looks everything is fine even with the ddeterminate command. Try changing the command to DDETerminateAll. Some rslinx packages only offer one topic (one device) or none. Rslinx OEM and rslinx PRO handle multiple DDE's. Rslinx single node is the name says - a single device , so one dde. rslinx lite - no dde support. Sub ReadClick() Dim UsedTopic As String UsedTopic = Cells(1, 1) rslinx = OpenRSLinx(UsedTopic) 'Reading code goes here DDETerminateAll End Sub Edited 19 Jul 2020 by Izzybe 1 person likes this Share this post Link to post Share on other sites
Posted 20 Jul 2020 16 hours ago, Izzybe said: @HuntWhenever, at first glance it looks everything is fine even with the ddeterminate command. Try changing the command to DDETerminateAll. ... When I try DDETerminateAll, I get a "Sub or Function not defined" compile error. Share this post Link to post Share on other sites
Posted 22 Jul 2020 Interesting DDETerminate works while DDETerminateAll doesn't. Does DDEPoke or DDERequest work on your script? run your code in debug mode, and step through each line. Keep your online tags short maybe one in case of troubleshooting. In your vb editor tools --> go to references. Dialog box will open and look for the missing library, the last library with a checkmark will start with missing and then its name. check the missing library and then hit ok. Otherwise you need to call it out as an Application.DDETerminateAll 1 person likes this Share this post Link to post Share on other sites
Posted 22 Jul 2020 27 minutes ago, Izzybe said: Interesting DDETerminate works while DDETerminateAll doesn't. Does DDEPoke or DDERequest work on your script? run your code in debug mode, and step through each line. Keep your online tags short maybe one in case of troubleshooting. In your vb editor tools --> go to references. Dialog box will open and look for the missing library, the last library with a checkmark will start with missing and then its name. check the missing library and then hit ok. Otherwise you need to call it out as an Application.DDETerminateAll DDEPoke works. I've stepped through the program a few times using a break point before and after the DDETerminate just to make sure it was executing that line. I looked through references, but the DDE functions are part of the Excell.Application as far as I know. I looked in the VBA object library. DDETerminate was listed in the Excell.Application class, but DDETerminateALL was not listed (image attached). Share this post Link to post Share on other sites
Posted 22 Jul 2020 Thanks for your reply :) I dont have the single node version. The only way would be to open and kill your actual rslinx application within your readclick() subroutine. Sub ReadClick() Dim vPID as Variant Dim UsedTopic As String 'point to your rslinx location vPID=shell("C:\programs\rockwell automation\rslinx.exe", vbNormalFocus) UsedTopic = Cells(1, 1) rslinx = OpenRSLinx(UsedTopic) 'Reading code goes here DDETerminate rslinx 'your code for terminating rslinx program from your pc. 'dim '.... see below note what to insert 'end if End Sub There is a sample code on this forum on how to close notepad. Replace notepad with rslinx.exe (what is shown in your task manager as running process name) You would copy from first dim --> to end if command and paste it to http://www.vbaexpress.com/kb/getarticle.php?kb_id=811 keep me posted 1 person likes this Share this post Link to post Share on other sites
Posted 22 Jul 2020 Interesting work around. I'll give that a try here in a few days. Thanks! Share this post Link to post Share on other sites