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 have a Sinumerik 828D control panel and its for a CNC machine, the problem is that it gives an error state 700027 tool turret state :S4...
Replies
0
Views
10
I am having a problem communicating my PLC with Drive via Modbus connection. I start by opening the port and there is no problem, but then when I...
Replies
5
Views
64
Hello all, I am currently trying to establish a message instruction to pass data from a 1756-L73 to a 1756-L71. My communication path from the...
Replies
8
Views
159
Dear sir, I am using SIMATIC 300, CPU 315-2DP , (6ES7 315-2AF03-0AB0) VIPA 603-1CC21 A1.0 RAM 32KB, Firmware=V4.0.8 The problem Im using MPI...
Replies
1
Views
65
Hi all, I am having an issue where some of my HMI push Buttons and Indicators go in to error when I navigate to a new screen. I am using a...
Replies
16
Views
329
Back
Top Bottom