Posts by tsiou

    Re: Send Data to PLC with DDE connection.


    Code
    Sub Poke()
    Channel = Application.DDEInitiate("GatewayDDEServer", "Kateris_13_2.pro")
    Set RangeToPoke = Worksheets("Sheet1").Range("B1")
    Application.DDEPoke Channel, ".excel_in_1", RangeToPoke
    Application.DDETerminate Channel
    End Sub
    
    
    Made it work with this code. It needs the RangeToPoke to set the value. So this code, will assign in "excel_in_1" variable of the PLC any value inserted in B1 cell.

    Hi all. I connected my PLC to an Excel sheet via DDE. I am able to read and copy the values that I want. So, far so good. What I am trying to do (with no success) is to send data to the PLC from EXCEL. I am trying using DDE commands in VBA but nothing happens. If anyone can help. Here's my code.


    Code
    Sub SendValue()
        Channel = Application.DDEInitiate("GatewayDDEServer", "Kateris_13_2.pro")
        Application.DDEPoke Channel, Sheets("Example").Range("E5"), Sheets("Example").Range("E7")
        Application.DDETerminate Channel
    End Sub



    In "E5" I have the data (its a number) and in E7 I have my variable. So, I want the plc to setas valueto the variable in E7 the data from E5.

    Re: SaveCopyAs without macros


    i am using Office 2010. I want when the user closes the Workbook a copy to be made in a specific folder. Seems easier with the code i wrote. Maybe snB's code be better, but i dont know how to use it. I am new to VBA and its not really me area. Thank god its over for me.

    Re: SaveCopyAs without macros


    Managed to do it writing this, if anyone is interested. Changed "SaveCopyAs", because it wouldn't let me change the format.

    Code
    Sub Workbook_BeforeClose(Cancel As Boolean)
        Dim sFile As String
    sFile = "METRISEIS" & Format(Now, "ddmmyyyy_hhmm") & ".xlsx"
    ActiveWorkbook.SaveAs Filename:="C:\METRISEIS\" & sFile, FileFormat:=51
    End Sub

    Re: SaveCopyAs without macros


    I bought it already. I am reading it. I am reading forums. I am trying. It's just that I have to deliver it the next two days and this is the last problem. If I fix this I ll be ok. I am just asking for help. If anyone can help, I 'll be grateful.

    Re: SaveCopyAs without macros


    Can you explain it to me further? I have a workbook with VBA code. Ok? It does what it does the code and I put the SaveCopyAs code as I mentioned to save a copy. Now, you are telling me to put the code you placed where?? And what will this code do? Will my workbook run the macros as template? Sorry, but I am new to VBA.

    Hi all. I am using this code placed in ThisWorkbook


    Code
    Sub Workbook_BeforeClose(Cancel As Boolean)
    ActiveWorkbook.SaveCopyAs "C:\METRISEIS\" & "Data" & Format(Now, "ddmmyyyy_hhmm") & ".xls"
    End Sub



    so anytime the user closes the Workbook, a copy will be saved at the specified directory. I use SaveCopyAs because I don't save the original. I use it as a blank form, so I needed to stay without data when I close it. Everything works fine, but the copy has macros on it. So when the user opens it and closes it, it makes a copy of itself. How can I disable macros at the copies? Thanks.

    Re: Add a counter column that will increment the number of the rows (1,2,3..)


    That's why I didn't want to sent a sample xls. Well in Column A I have live data from a PLC. Those data I manage to copy in Columns C,D,E,F. So whenever the robot that has the PLC on gives new values, a new row in inserted with values at Columns C,D,E,F. Ok now I get it. My bad. Not an actuall new row. A new row of data I mean. And I wrote a code so that every new row of data will have a time stamp (Column G). In the sample I used only Column C with data and D as time stamp. Its the same. What I want is every time a new row of data is inserted like C2=1786, D2=2129, E2=83, F2=8 and G2=08/03/14 11:54, in Column B a number to appear. So B2=1 (meaning 1st part of data from the PLC). When row 3 will be filled with values B3=2 etc...

    Re: Add a counter column that will increment the number of the rows (1,2,3..)


    forum.ozgrid.com/index.php?attachment/59365/


    Here's a sample. You can see my code. Maybe you can take a look at the Workbook_BeforeClose problem. It doesn't do what is supposed to do. I don't have a copy when I close the workbook. Anyway, this is the code. Everytime I have new data new a new row is added. I want an index column as I said if it's possible. Column B for example to have values 1,2,3.... everytime a new row is inserted.

    Re: Add a counter column that will increment the number of the rows (1,2,3..)


    I attached my Workbook. In column A I have a live feed of data from a PLC. In columns C,D,E and F I copy the data as the come. I also put in G Date & Time stamp. Now what I want is, whenever a new row is added on C,D,E,F & G a increment number t o added on column B. Like B2=1, B3=2, B4=4 etc... No mystery here, only a tired male engineer.


    [ATTACH=CONFIG]59351[/ATTACH]