DDE Refresh and clean up

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
alexan
Posts: 16
Joined: Fri Feb 22, 2008 9:25 pm

DDE Refresh and clean up

Post by alexan »

Hello Everyone,

I have a problem with DDE. I have a spreadsheet with hundreds of DDE link to another application: =DDE(Provider;"Variable";DestinationCell)

Everytime I open the spreadsheet I need to manually brake links, close and open 2/3 times the application to make it work. Also Calc appears to
store old DDE links to object no longer in the spreadsheet...

Is there a way to select all or part of the DDE links via code and clean them up?

Thanks!

Note: I already have a post in Calc for more details: http://user.services.openoffice.org/en/ ... f=9&t=3971

Alex
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: DDE Refresh and clean up

Post by Villeroy »

To make this API topic more specific: The c.s.s.sheet.DDELinks pile up unless you manually remove the no longer used ones via Menu:Edit>Links... [Break Link]. There is no apparent API equivalent for this procedure.

Code: Select all

Sub Main
oDDELinks = thisComponent.DDELinks
myxray oDDELinks
print oDDELinks.getCount()
For i = 0 to oDDELinks.getCount() -1
	oLink = oDDELinks.getByIndex(i)
	'myxray oLink
Next
End Sub
Unlike other collections, the collection of DDELinks does not have method removeByIndex of interface c.s.s.container.XIndexContainer nor method removeByName of interface c.s.s.container.XNameContainer.
Last edited by Villeroy on Mon Mar 31, 2008 11:24 am, edited 1 time in total.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
alexan
Posts: 16
Joined: Fri Feb 22, 2008 9:25 pm

Re: DDE Refresh and clean up

Post by alexan »

Thanks for the details. Hopefully someone has some idea/solution!
ms777
Volunteer
Posts: 177
Joined: Mon Oct 08, 2007 1:33 am

Re: DDE Refresh and clean up

Post by ms777 »

Hi,

your problem seems to be solvable using the workaround shown in http://www.oooforum.org/forum/viewtopic.phtml?t=22845 .

I am willing to offer help, but I have no clue about using the DDE function. If you want to go that way, please post some DDE example, which e.g. shows a DDE link to a different calc sheet or writer file

Good luck,

ms777
alexan
Posts: 16
Joined: Fri Feb 22, 2008 9:25 pm

Re: DDE Refresh and clean up

Post by alexan »

Thank you,

I read your post and it might be the solution. All I need to do is automate breaking the links from the Edit menu. All with a click of a button.
So the macro will:

1) Open the edit menu
2) Select Links
3) Click on Break links
4) Click on Yes
5) Loop until done (sometime I might have hundreds of links...)

How can we do this?

Thanks again.

Alex
elysch
Posts: 1
Joined: Sat Oct 11, 2008 7:33 pm

Re: DDE Refresh and clean up

Post by elysch »

Have you been able to do this?

Could you share the solution?

Thank you in advance

Ely.
OOo 3.0.X on Ms Windows XP
alexan
Posts: 16
Joined: Fri Feb 22, 2008 9:25 pm

Re: DDE Refresh and clean up

Post by alexan »

No luck yet. I'm still breaking up the links manually. Didn't have enough time available to work more and
apparently no one has the same need or problem...really weird. I wonder how other users do with the DDE links...
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: DDE Refresh and clean up

Post by Villeroy »

I believe that the API lacks any method to break links. But even if you do so in the GUI, the link will be re-established on next calculation if there is a single pointer to the external source. You have also to remove or replace all the formulas related to that link.
If your macro does this by means of XReplace or something, you end up with the old links still in the list, but not in use effectively.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Post Reply