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.
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.
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, "", "")