Auto update file hyperlink

I am running LibreOffice 7.3.1 (x64) on Windows 10.

I have two files I’d like to link and keep updated as I modify the other:

The cell formula in file_B, which I’d like to keep updated is
=‘file:///D:/FILE_A NAME.ods’#$Teams.B1

The file does update when I open file_B but I’d like to keep file_B updated when I modify file_A.

I have ‘Data|Calculate|Autocalulate’ checked.

update: I would like a ‘live’ update … I change the ‘A’ spreadsheet and immediately the ‘B’ spreadsheet is changed when the ‘A’ is saved.

How is this done?

If you have focus on B you can do a hard recalculate, ctrl+shift+F9, whether or not A is saved. If you can get a handle for B within a macro in A, you could have that macro do a hard recalculate via the DispatchHelper passing in B.

Sub SaveEvent()
	Dim Frame As Object
	Dim Dispatcher As Object
	
	FileBComponentHandle = ...
	
	Dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
	Frame = FileBComponentHandle.CurrentController.Frame
	Dispatcher.executeDispatch(Frame, ".uno:CalculateHard", "", 0, Array())

End Sub

Maybe? I didn’t have any luck getting that handle via, say, Frame.LoadComponentFromURL using

Sub HardUpdateSink()
	Dim URL As Variant
	Dim Frame As Object
	Dim Dispatcher as Object
	Dim Sink As Object
	Dim Prop(1) As New com.sun.star.beans.PropertyValue
	
	URL = convertToURL("'file:///C:/.../Sink.ods'")
	Dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
	Prop(0).name="FilterName"
	Prop(0).value="calc8"
	Sink = ThisComponent.CurrentController.Frame.LoadComponentFromURL(URL, "_blank",0, Prop())
	Dispatcher.executeDispatch(Sink.CurrentController.Frame, ".uno:CalculateHard", "", 0, Array())

End Sub

Boiled down to LO saying I didn’t have sufficient user rights. Maybe others can shed light on that. It’s a little out of my comfort zone.

Copy all the data into one document or try:

=DDE("soffice";"D:\FILE_A NAME.ods";"Teams.B1")

Andreas,

Thank you for your reply. The DDE only updates when a file is opened. I would like a ‘live’ update … I change the one spreadsheet and immediately the other is changed when the first is saved.

Henry

This is how spreadsheets work. All data need to be loaded in memory.

DDE_Target.ods (12.5 KB)
DDE_Source.ods (12.4 KB)
Open both side by side.
Activate Source.ods.
Hit F9 to recalculate the formula. Source.ods will follow with a lag of a second.
When you open the target fiile without the source file, the source file is loaded in a hidden state.

The file:///url links store a hidden copy of the referenced source data within the target file. This means that you may send only the target file to another machine without losing the referenced data. Any update requires a manual update from an existing source file.


Of course, all this spreadsheet linking is rubbish. You should avoid that.