MrPLC Member
  • Content count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About ldrewes

  • Rank
    Hi, I am New!

Profile Information

  • Country United States
  1. Excel VBA to CLX data dump

    Holy Crap, That is exactly what I needed! You are indeed a wizard good sir. I can't thank you enough!  Now i'd be interested in looking through the VBA to figure out how it all works. Thanks again! (BobLFoot)It wouldn't let me post the "quote" but I'm refering to your Excel File you attached)  
  2. Excel VBA to CLX data dump

    BobLfoot, thanks for the reply. So I would have to convert the string or text information in excel to SINT format before i tried to send it for the PLC to accept it? Is this the same for OPC also? I agree with you that OPC would probably work better. I have looked at some OPC examples and as i mentioned not being very good with understanding VBA when i compared the DDE example to the OPC example, the DDE look like way less of a nightmare to figure out. But it looks like I will start looking down that route. 
  3. Excel VBA to CLX data dump

    Good afternoon, I'll start by explaining what i want to do and then what I've tried. We have an excel document at work that contains our material batch information and there is a column of data i would like to be able to dump into our control logix processor. This data could potentially need updated on a weekly/monthly basis so I am trying to find an easy way to do the transfer. I know how to do the DDE connections and can get individual cells to show or write individual tag information. But what would be the best way to take a whole column of data and dump it into a sequential array in logix? I did find a DDE VBA example that did this however I have not been successful. I got the example to work in its original setup using my DDE connection information but when I tried to change it to do what I needed, RSLinx crashed and it just keeps not working or doing anything. Is there a numerical limit on how many i can write in this one operation and also the data i am trying to write is going into a string datatype. Does that matter? I will admit I have a VB code reading and understanding skill of about a first grader. Here is the VBA code Private Function OpenRSLinx() On Error Resume Next 'Open the connection to RSLinx OpenRSLinx = DDEInitiate("RSLINX", "CND_EXCEL") 'Check if the connection was made If Err.Number <> 0 Then MsgBox "Error Connecting to topic", vbExclamation, "Error" OpenRSLinx = 0 'Return false if there was an error End If End Function Private Sub CommandButton2_Click() rslinx = OpenRSLinx() 'Open connection to RSlinx 'Loop through the cells and write values to the CLX array tags For i = 0 To 50 'Get the value from the DDE link realdata = DDERequest(rslinx, "Batch_DB_Test[0][" & i & "],L1,C1") 'If there is an error, display a message box If TypeName(data) = "Error" Then If MsgBox("Error reading tag Batch_DB_Test[0][" & i & "]. " & _ "Continue with write?", vbYesNo + vbExclamation, _ "Error") = vbNo Then Exit For Else 'No error, place data in CLX DDEPoke rslinx, "Batch_DB_Test[0][" & i & "]", Worksheets("Sheet2").Cells(2 + i, 7) End If Next i 'Terminate the DDE connection DDETerminate rslinx End Sub Is there anything obvious I am doing wrong? Is this the best/easiest way to do this? I don't have any experience with RSQL or anything like that which I think might be the "Right" way to access databases or large amounts of information but again i have zero experience in that. Sorry for the really long post but I am pretty stuck and I'm almost sure this is possible...but maybe not. I always appreciate all your help! Thank you!! Let me know if there is any needed information I left out.