Page 1 of 1

DDE Excel ActiveCell value

Posted: 17 Sep 2013 15:48
by Tonton Luc

Is it possible to recover the Excel sheet active Cell value using DDE ?
I've tried this following code without succes :

Code: Select all

_ = vpiDde::request(Conv,"Cells(activecell.Row,15)",1000,vpidde::cf_Text,Val),

My DDE handling in VIP 5.2

Posted: 20 Sep 2013 9:45
by Ferenc Nagy
Hi Tonton,

I handled Excel with DDE in my old Portable Spent Fuel Attribute Test Program.
I handled a fixed cell not the active one.
I was angry with the Microfos that I could not fiend a usable docomentation of the DDE.
;-) Bad Hungarian joke with the name of French General Foche of Word War I pronounced as "Fos" in Hungarian where the later is the product of metabolism in case of Moctezuma's revenge.

Code: Select all

task_win_eh(_Win,e_Menu(id_eval_view,_ShiftCtlAlt),0):-!,         % View results by Excel program         % NullWin = cast(WINDOW, 0),         % View results using Excel         TaskWin = vpi_GetTaskWin(),         msg_vpi_getresstr(ev_excel_how ,Ex_how , "\t"),         msg_vpi_getresstr(ev_excel_name,Ex_name, "\t"),         %Init_Excel = "C:\\Progra~1\\Micros~1\\Office\\Excel.exe",         Init_Excel = "\"C:\\Program files\\Microsoft Office\\Office\\Excel.exe\"",         Excel = dlg_GetStr( Ex_how, Ex_Name, Init_Excel ),         my_msg_appendstr(Excel,"\n"),         ApplicationId = vpi_CreateProcess( TaskWin, Excel, "", wsf_Maximized ),         dde_Init([ddef_clientonly]),         dde_Connect_to("Excel", "", max_wait, max_sleep, Conv),         dde_EnableEvents(Conv, b_false),         dde_Poke(Conv, "R1C1", str("Application.Run \"FuelOpen\""),ddecf_text, 0),         dde_DisConnect(Conv),         dde_End,         !.
Please inform me if you find a valuable DDE documentation for Excel.

Posted: 24 Sep 2013 8:48
by Tonton Luc

I've found what I need :

Code: Select all

_ = vpiDde::request(Conv,"LC15",1000,vpidde::cf_Text,ActiveCellValue),
Using this code, I recover the contain of the active cell in colum 15.

This is not the solution

Posted: 25 Sep 2013 12:01
by Ferenc Nagy

This is not the solution of your original problem.
If you know that you have to poke your result in that cell then it may be work.
But if you have an Excel Workseet which active cell is being moved by another program or another user then the value counted by your Prolog program goes not the active cell but to a fixed address.

Posted: 27 Sep 2013 8:04
by Tonton Luc
Hi Frank,

When I use this DDE code from my VP application, the Excel Sheet is of course always ALREADY open manually by myself, and I always put manually the activeCell in one specific line.

Many thanks for your thoughtfulness.