Discussions related to Visual Prolog
User avatar
Tonton Luc
VIP Member
Posts: 204
Joined: 16 Oct 2001 23:01

DDE Excel ActiveCell value

Unread post by Tonton Luc »

Hi,

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),
User avatar
Ferenc Nagy
VIP Member
Posts: 215
Joined: 24 Apr 2007 12:26

My DDE handling in VIP 5.2

Unread post 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.
TIA, Regards,
Frank Nagy
User avatar
Tonton Luc
VIP Member
Posts: 204
Joined: 16 Oct 2001 23:01

Unread post by Tonton Luc »

Hi,

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.
User avatar
Ferenc Nagy
VIP Member
Posts: 215
Joined: 24 Apr 2007 12:26

This is not the solution

Unread post by Ferenc Nagy »

Tonton,

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.
TIA, Regards,
Frank Nagy
User avatar
Tonton Luc
VIP Member
Posts: 204
Joined: 16 Oct 2001 23:01

Unread post 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.
Post Reply