Home Image-Pro Plus Automation with Macros

IpProfSave("", S_DDE) - set column

(Originally posted by Optiker on 12/27/2005)

In passing data to an Excel worksheet, I found the command IpProfSave("", S_DDE) by recording a macro. I didn't find that command in HELP/Macro Language.

I would like to reset the location of the upper-left corner of the data array to (1,1) in the worksheet each time I run the macro, but need to step one column at a time as the macro loops.

In the Profile File/DDE Options window, if I check "Append Data set to the right" I get the columns stepping as I loop. But, the next time I run the macro, it picks up in the column to the right of where it left off.

How do I reset the column number to 1 each time I run the macro? It must be documented some place, but I didn't find it, and I'm not understanding the HELP section on DDE enough to know what to do. Can anybody help with the lines of code I need to reset the column to 1 each time I run the macro?

Comments

  • (Originally posted by YuriG on 1/3/206)

    You can set start row/column by the following commands:
    ret = IpDde(DDE_SET, "row", "5")
    ret = IpDde(DDE_SET, "col", "8")
    ...
    ret = IpProfSave("", S_DDE+S_DATA)

    You can find more information on IpDde page of IPP macro help or just by recording a macro in DDE Options (Data Exchange Options) dialog.

  • Do you know how to use a variable as the row or column number in the above code? I have a for loop where the column number should be the index of the loop. Yet it simply pastes data sequentially when found. For example, I am counting and sizing objects found in an array of images. Suppose I have a 4x4 array. Image 1 has objects while images 2-8 do not, then image 9 does. The code that I have pastes into columns 1 & 2 the data where as I want it to be columns 1 & 9. The IpDde(DDE_Put...) command works fine, yet if the Else part is entered the code then overwrites the 0's that were written by the first Put command. It seems that the Put command doesn't actually select the cell defined as (1,cmeasure) and I can't figure out how to do that.

    If numobj<1 Then

                            ret = IpDde(DDE_SET, "col", "cmeasure")

                            ret = IpDde(DDE_SET, "row", "1")

                            ret = IpDde(DDE_SET, "target", "excel")

                            ret = IpDde(DDE_SET, "topic", "[Book1]Sheet1")

                            ret = IpDde(DDE_PUT,"R1C" & cmeasure, "0.000")

                      Else

                            ret = IpDde(DDE_SET, "col", "cmeasure")

                            ret = IpDde(DDE_SET, "row", "1")

                            'ret = IpDde(DDE_SET, "append", "2")

                            ret = IpDde(DDE_SET, "target", "excel")

                            ret = IpDde(DDE_SET, "topic", "[Book1]Sheet1")

                            ret = IpBlbSaveData("", S_DATA+S_DDE)

    End If


    Any ideas are helpful!

    Thanks.

  • 2019-03-18-102234

    BCHARLES --

    The AUTO-PRO 7.0 HELP FILE (AUTO-PRO.CHM) contains some sample code on the page for

        IpDde

    that addresses this.

    One section is similar to the code that you have.

    I do not know why this is not working properly.

    Another section of code (included below) uses another method to move data from IMAGE-PRO to EXCEL through the WINDOWS DDE MECHANISM.

    Perhaps this method will work for you and your app.

    I hope this information is helpful.

    -- MATT

    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

    q$ = chr$(34) ' ASCII code for quote.

     

    ' Open communication with sheet1 of Excel

    ret = IpDde(DDE_OPEN, "excel", "sheet1")

     

    ' Put value 1.234 into cell on 2nd row and 3rd column.

    ret = IpDde(DDE_PUT, "R2C3", "1.234")

     

    'Get value back from Excel

    Dim tmp$ as string * 100

    Dim retval as single

    ret = IpDde(DDE_GET, "R2C3", tmp$)

    retval = val(tmp$)

     

    ' Execute commands in Excel:

     

    ' Open communication with Excel itself

    ret = IpDde(DDE_OPEN, "excel", "system")

     

    ' Select sheet2

    ret= IpDde(DDE_EXEC, "[ACTIVATE(" = q$ +"sheet2" + q$ + ")]", "")

     

    Select cell in first row and 9th column

    ret = IpDde(DDE_EXEC, "[SELECT(" + q$ + R1C9" + q$ + ")]", "")

     

    'Paste contents of clipboard

    ret = IpDde (DDE_EXEC, "[PASTE()]","")

     

    ' End communication

    ret = IpDde (DDE_CLOSE, "", "")


Sign In or Register to comment.