6

Connecting Excel with 'ABC' throught Excel works, connecting R with Excel by DDE works also, but how to connect R with 'ABC' application ?

I have application providing DDE interface, from Excel I could retrieve value from it with this DDE reference :

='ABC'|DDE!_nazwa_value

from R I've tried to use tcltk2 library, as follows :

tcltk2::tk2dde.request(service="ABC", topic="DDE", item="_nazwa_value")

but error occurs :

Error in structure(.External(.C_dotTcl, ...), class = "tclObj") : 
  [tcl] remote server cannot handle this command.

[1] "Error in structure(.External(.C_dotTcl, ...), class = \"tclObj\") : \n  [tcl] remote server cannot handle this command.\n\n"
attr(,"class")
[1] "try-error"
attr(,"condition")
<simpleError in structure(.External(.C_dotTcl, ...), class = "tclObj"): [tcl] remote server cannot handle this command.

I'm only trying to use tcltk dde functions to retrieve data from application, I think that item part of my tk2dde.request is wrong, but I've tried various modification (without _ for example), do you know any clues or resources for solving this problem ?

EDIT

something is wrong I don't see ABC server nor DDE topic on server-topic list : tk2dde.services() but Excel can still connect and retrieve value using ='ABC'|DDE!_nazwa_value, DDE Query also do not see it

Qbik
  • 5,885
  • 14
  • 62
  • 93
  • 1
    Would making `item` be `_nazwa_value` (without `{…}`) work? I'm totally on the wrong platform to check… – Donal Fellows Sep 10 '18 at 09:04
  • @Donal Fellows good try, but error is the same as above, mayby I should consider issues like registering DDE server, but Excel client works perfectly well so registering server seems to be not the issue and I could also make workaround and get data to Excel from 1ABS1 application and next from Excel to R with request tcltk2::tk2dde.request("Excel", "Data", "R1C1:R25C25") and it works perfectly well – Qbik Sep 10 '18 at 17:57
  • Why the curly braces around "_nazwa_value"? – L. Alejandro M. Sep 12 '18 at 23:09
  • Who have marked my question as favorite ? – Qbik Sep 17 '18 at 13:54
  • 1
    I don't think StackOverflow allows users to know who marks questions as favourite, but maybe that person wants to find the solution to your problem too. – Jerry Sep 18 '18 at 07:08
  • Have you tried using the Tcl `dde` package directly, `package req dde; dde request ...`? – mrcalvin Sep 18 '18 at 10:13
  • @mrcalvin there is no `dde` package at CRAN – Qbik Sep 18 '18 at 12:09
  • I am referring to the Tcl package `dde`, that should come with windows builds of Tcl (and so with the Tcl bundle coming with R). What gives (untested):`.Tcl("package req dde")`? – mrcalvin Sep 18 '18 at 12:42
  • @mrcalvin it gives ' 1.4.0' – Qbik Sep 18 '18 at 23:27
  • 1
    So, assemble and send your request in Tcl, for a try: `.Tcl("package req dde; dde request ABS DDE _nazwa_value")` – mrcalvin Sep 19 '18 at 15:14
  • Is your server name `DDE`? From the documentation it looks like `topic` should be the server name. – Mako212 Sep 19 '18 at 18:01
  • 1
    Try the cmd line utility ddecmd. `shell("ddecmd request -s ABC -t DDE -i _nazwa_value", intern = TRUE)` . http://www.chrisoldwood.com/win32/ddecmd/ddecmd.html – G. Grothendieck Sep 23 '18 at 04:16
  • 1
    One other thing to try would be to try tcltk2 from both 64 bit R and 32 bit R versions. – G. Grothendieck Sep 23 '18 at 11:55
  • @Mako212 by Ive used 'DDE' as server name : `topic="DDE"` is it proper - I don't know, how to list server names ? DDESpy don't show everything – Qbik Sep 25 '18 at 12:03

1 Answers1

2

You can read in the article about DDE in tcl/tk wiki:

(Talking about using Internet Explorer) ... All of the above experiments should "work" reliably, in that, from the user perspective, IE indeed acts as described. However, back in the Tcl process, [dde] typically throws a "remote server cannot handle this command" exception. That's because, in KBK's analysis, DDE gives no "way to distinguish 'result expected, but the server failed to provide it' from 'no result is expected'." The only way not to receive a DMLERR_NOTPROCESSED is to invoke "dde exec -async ..."

Note: i tried tcl examples of DDE using Excel + "request" and i got the same error as you: "remote server cannot handle this command".

Saludos!,

L. Alejandro M.
  • 619
  • 6
  • 14
  • but connecting with those application with Excel through DDE works, connection from R to Excel by DDe works also, I simply don't know how to connect R directly with 'ABC' application – Qbik Sep 21 '18 at 14:44
  • 1
    You could connect from R to Excel with tcltk2?. If yes, what "parameters" you've used? – L. Alejandro M. Sep 21 '18 at 18:46
  • tk2dde.request("Excel", "Sheet1", "R1C1:R101C25") - simple request which doesn't contain name of file – Qbik Feb 25 '19 at 17:29
  • request : tk2dde.request("Excel", "{[filename.xlsm]Data}", "R1C1:R1C1") also works – Qbik Feb 25 '19 at 17:31