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

Hi Siemens guys! I am experiencing SF fault on our S7-300 (6ES7 315-2AH14-0AB0) CPU from time to time. I've checked the diagnostic buffer and...
Replies
13
Views
114
Hello..I am new to Plc.I have Mitsubishi Melsec Fx3Ga-40MR PLC controlling a machine for packing powder.Currently the Plc has issue which power...
Replies
3
Views
75
hello, I'm a student and for my final grade I have to repare a sepro robot. the only problem I have for now is that i have an error code 3...
Replies
0
Views
30
Dear All, i am trying to connect Danfoss inverter with s7 200 cpu 226.but microwin shows following error at DATA Ptr.i assigned different VB...
Replies
1
Views
40
Hi everyone, i have a Siemens S7-300 Cpu 314C-2 DP with several cards of i/o and servos my laptop has TIA version 16 and 17 loaded and...
Replies
4
Views
132
Back
Top Bottom