DDELinks, how to interrupt them without touch cells formulas

Does anyone know how to write a macro that breaks the links in the SAME way as the button in the figure? If the button does this, then the code exists to break the DDELinks. Thank you.
Senza nome2

Interrompí collegamento = Broke connection

You have to use some other type of link. When you break a DDE link, save and reload the client file, the DDE formula returns #N/A.

Ok, thanks Villeroy for the contribution, but is it possible to delete the list of links automatically through a macro? Sometimes LibreOffice crashes if the links are wrong (i.e. source file has been deleted) and I would like to prevent this automatically because the user gets angry.

When you enter a DDE formula, the formula will be evaluated and generate a DDE link. You have to remove or replace the formulas, otherwise you get new links every time the document is recalculated.

I agree with you Villeroy if the formulas are static, few and the end user is capable. If instead formulas are as many as these = VLOOKUP ($ B2: $ B500; DDE (“soft”; filename; “$ sheet1. $ D $ 1: $ K $ 1048576”); 2; 0) where filename is a value of a cell that can change continuously, I will have a DDELinks list that grows out of all proportion and must be managed automatically.

Well, then handle it automagically. But first you’ve got to find out what to do with all these formulas with invalid references.

The following will replace DDE formulas with the formula string:
[X] All sheets
[Other Options]
Search in: Formulas
[X] Regular expressions
Find: ^=.*DDE\(
Replace: '&
This should find everything starting with an equal sign and having “DDE(” somewhere. This string will be replaced with a leading apostrophe and the matched string itself, effectively adding a leading apostrophe. The cell’s text will be the formula without the leading apostrophe.

In current versions the resulting text will include the leading apostrophe (if the remainder couldn’t be converted to numeric). Starting with 7.5 all input in a cell not formatted as Text will have a leading apostrophe removed and the remainder set as text content, see ReleaseNotes/7.5 - The Document Foundation Wiki .

Btw, the search expression needs to escape the opening parenthesis: ^=.*DDE\(

1 Like

It is not needed. In fact, filename is the name of an area or cell (for example C32) where the name of the source file is inserted. I just have to change the incorrect value present in the reference cell filename (C32) and everything goes back to normal if it were not for the DDELinks list which has now grown.