I have an Excel macros that can't connect with KEPServer using Visual Basic.
The thing is that for some versions of windows computers can connect with it while for others can't. Currently I'm using windows 10, Excel 2010 and KEPServer 5.13. The macros used to work perfectly, so some kind of windows update must have make it fail.
The program fails while doing a DDERequest and it returns the Error 2023. I also noticed that KEPServer keeps giving the following error:
Date Time Level Source Event
21/01/2020 16:57:23 Error DDE Attempt to add DDE item 'TOOL1.PLC.MESCADA_BoxProductionCounter' failed.
The Vba used code is:
Private Sub Establish_Connection_Click()
Dim Tmp_Old_BoxProductionCounter As Variant
RSIchan = DDEInitiate("kepdde", "_ddedata")
Estat_Conexio.Text = " Connected to hardware "
Mode = "Automatic"
Tmp_Old_BoxProductionCounter = DDERequest(RSIchan, "TOOL1.PLC.MESCADA_BoxProductionCounter")'<-- It fails here
Old_BoxProductionCounter = Tmp_Old_BoxProductionCounter(1)
Call Worksheet_Activate
collected_rows = 2
Initiate_Study.Enabled = False
...
It uses NetDDE to connect with the KEPServer. I know it is obsolete and think that might be the problem and there is a more modern way to do it, using OLE, but I dont really know how to do it and if it will even work.
What do you think I can do in order to fix it or if it exists any way to connect them using OLE?