Trying to exchange data using DDE with an other application

I am developing an application with the delphi language that exchanges data through DDE with LibreOffice Calc.
I can’t get a link using:
Setlink(‘soffice’,’[myFileName]Sheet1’);

I would like to write in a cell, for example cell A1.
But the Setlink function returns false.
What is the exact syntax for ‘[myFileName]Sheet1’?

thanks

How is [myFileName] described? Hopefully you are using the full URL format like 'file:///full_path/myFileName'#$Sheet1.A1. Try copying cell A1 in your source and first paste it into a cell in a new spreadsheet as a DDE link. You will get something similar to {='file:///C:/Tests/Test.ods'#$Sheet1.A1} Try using this syntax in your application. (I’m not sure if this will help - I’ve never encountered such a task in practice: if I needed a value from a spreadsheet, I opened the file in hidden mode and read the required values explicitly)

Hi John,
Thank you for your answer.
I havetried many things but none of them works:
‘file:///c:/tmp/dde.ods’#$Sheet1.A1
‘file:///c:/tmp/dde.ods’#$Sheet1
‘c:/tmp/dde.ods’#$Sheet1.A1
‘{=file:///c:/tmp/dde.ods’#$Sheet1.A1}
‘{=file:///c:/tmp/dde.ods’#$Sheet1}

The only one that works is “system”, I can link with “system” but I can’t execute a command.
I don’t know witch command is recognized by LibreOffice, I tried the same one I use for Excel but it doesn’t work ([NEW(1)] , [File.Close()] , [Run(“MyMacro1”)] ) but that is another question.

I’m sure you already did THIS, but I had to ask.

here is exactly what I do:

  var DdeClientConv1 := TDdeClientConv.Create(application);
  if not(DdeClientConv1.SetLink(ServiceStr,TopicStr)) then ShowMessage('Error: cannot set the link using '+ServiceStr+' and '+TopicStr);

It does not work with Writer either
But with Excel and Word, it works

I have developed a DDE test software that you can download here to test with Libre office :
https://www.riber.com/test/

no more suggestion to my problem ?
Thanks,
Franck

Please take a look to DDE function
https://help.libreoffice.org/latest/en-US/text/scalc/01/04060109.html?DbPAR=CALC#bm_id3148727

It should do what you like, you can try to copy on the source app and past-special in LibreOffice, selecting DDE to paste.

Thank you Mario but my question was relative to the communication through DDE from an external application. This link is about the DDE function which is used in VBA macros. But thank you for your effort.

No, it is not about VBA, it is the Calc DDE() spreadsheet function.

Mario, I already use this spreadsheet function DDE() and it works.
My problem is that I am developing a windows application (with delphi) and from this application, I would like to exchange data with LibreOffice using the DDE. I can do it very well with Excel or Word but not with libre office. I use the DDE test software above (in the above post) with the “soffice” service but I can’t initiate a dialog.
I can only initiate a link with the service “soffice” and the topic “system” but not with the current document.

You can not write in Calc using DDE.

The DDE syntax the soffice application accepts for Calc is the spreadsheet file name as topic and a cell or cell range reference as item, like Sheet1.A1. File name and reference concatenated in one argument won’t work. It may work for the Excel case because historically there each sheet was one file and they stick to that weird [filename]sheetname notation left and right.

I just tried several more solutions but none of them work.
I tested with the following topics
test.ods
[test.ods]
c:\temp\test.ods
[c:\temp\test.ods]
[c:/temp/test.ods]
[file:///c:/temp/test.ods]

None of them work, the Setlink function always returns false.

Bracketed [...] file names certainly won’t work as the brackets would be part of the file name. Best bet would be one of
c:/temp/test.ods
file:///c:/temp/test.ods
But I have no clue if this kind of connection (connect, keep open, request items later) even can work with LibreOffice as DDE server as the implementation is very simplistic.
You’re probably better off using the LibreOffice UNO API to access document content (that can also be used to write, which was the initial desire but wouldn’t work with DDE anyway). See https://api.libreoffice.org/ .

Thank you erAck but I tried both (c:/temp/test.ods and file:///c:/temp/test.ods) and it does not work.
I would love to offer libreoffice to my clients instead of using microsoft word… I am sure there is a solution but which one ? The only topic with wich I can initiate a DDE conversation is “system”