error 2023 when connecting excel to plc

NoLegalMoves

Member
Join Date
Jul 2012
Location
Utah
Posts
6
I can't figure out what is not working...

Private Function OpenRSLinx()
On Error Resume Next

'Open the connection to RSLinx
OpenRSLinx = DDEInitiate("RSLINX", "PLC15")

'Check if the connection was made
If Err.Number <> 0 Then
MsgBox "Error Connecting to topic", vbAbortRetryIgnoreExclamation, "Error"
' OpenRSLinx = 0
End If

End Function

Sub Button1_Click()

Dim i As Integer


'write to PLC15
rslinx = OpenRSLinx() 'Open connection to RSlinx

'Loop through the cells and write values to the CLX array tags
For i = 0 To 9

'Get the value from the DDE link
realdata = DDERequest(rslinx, "CLN_823L31_3101_SPT[" & i & "],L1,C1")
'If there is an error, display a message box
If TypeName(realdata) = "Error" Then
If MsgBox("Error reading tag CLN_823L31_3101_SPT[" & i & "]. " & _
"Continue with read?", vbYesNo + vbExclamation, _
"Error") = vbNo Then Exit For
Else
'No error, place data in CLX
Cells(i, 2) = realdata

End If

Next i

'Terminate the DDE connection
DDETerminate rslinx

End Sub
 
I can't figure out what is not working...

Private Function OpenRSLinx()
On Error Resume Next

'Open the connection to RSLinx
OpenRSLinx = DDEInitiate("RSLINX", "PLC15")

'Check if the connection was made
If Err.Number <> 0 Then
MsgBox "Error Connecting to topic", vbAbortRetryIgnoreExclamation, "Error"
' OpenRSLinx = 0
End If

End Function

Sub Button1_Click()

Dim i As Integer


'write to PLC15
rslinx = OpenRSLinx() 'Open connection to RSlinx

'Loop through the cells and write values to the CLX array tags
For i = 0 To 9

'Get the value from the DDE link
realdata = DDERequest(rslinx, "CLN_823L31_3101_SPT[" & i & "],L1,C1")
'If there is an error, display a message box
If TypeName(realdata) = "Error" Then
If MsgBox("Error reading tag CLN_823L31_3101_SPT[" & i & "]. " & _
"Continue with read?", vbYesNo + vbExclamation, _
"Error") = vbNo Then Exit For
Else
'No error, place data in CLX
Cells(i, 2) = realdata

End If

Next i

'Terminate the DDE connection
DDETerminate rslinx

End Sub
Did you ever find a solution to your Error 2023? I am having the same issue.
 
sorry i dont think so.. i stopped working on this a while back

NoLegalMoves,

Looking at you code there are some discrepancies, please see below.

Here a list of items that I would check and/or modify:

1) Check that you have a valid DDE Topic in RSLinx named "PLC15"
2) In [Private Function OpenRSLinx()] - Replace "vbAbortRetryIgnoreExclamation" with "vbExclamation"
3) Comment out [Dim i As Integer] - Don't Need This
4) Uncomment [OpenRSLinx = 0]
5) Verify that "CLN_823L31_3101_SPT" is a REAL and the number of elements in your array matches, in your case the For i value or 10.
6) Cells(i, 2) = realdata is reading from the PLC to Excel not Writing to PLC. To write the "values" back into the PLC, you would use something like this:
DDEPoke rslinx, "CLN_823L31_3101_SPT[" & i & "]", Cells(i, 2)
7) If you have more than "1" worksheet, you MUST specify the worksheet that you want to read to or write from.

Hope this helps.

K
 
Last edited:

Similar Topics

I'm trying to compare strings in Studio 5000 on an Allen Bradley 1769-L33ER and came across this weird incorrect string comparison. Neither of the...
Replies
9
Views
130
Hi All, I bought an old machine and I'm trying to get it running. It's a Pemas injection molding press running a Sigmatek control system with a...
Replies
0
Views
37
Hello, When I try to read from the PLC, the following error occurs: There is no project name. Failed to read the intelligent function module...
Replies
1
Views
78
Hello everyone I have the next issue with FactoryTalk Linx, when i configure the Ethernet driver and try to find the IP Address of the PLC Device...
Replies
0
Views
60
Hi, First time user of S5 Siemens. Is there any solution on how to solve this kind of error. HMI OP7 $613 DB-error No. 11 (0: 15) Siemens PLC...
Replies
9
Views
173
Back
Top Bottom