Welcome!
Executing scripts from the command line has been discussed in several threads here, you can easily find them if you need more information.
To done your work, do the following:
-
Choose Tools - Macros - Organize Macros - LibreOffice Basic, click the Organizer button.
-
In the My Macros & Dialogs section, create a new library, name it, for example, updateRefs.
-
Go to edit (upper right button) and rename the created Module1 to UpdateHidden
-
Paste the following code into the module:
Option Explicit
Sub updateAndSave(sSourcePath As String)
Dim sPath As String
Dim oDoc As Variant
Dim loadComponentProperties(0) As New com.sun.star.beans.PropertyValue
Rem Prevent screen flashing - perform file upload in "stealth mode"
loadComponentProperties(0).Name= "Hidden"
loadComponentProperties(0).Value= True
Rem We can load the spreadsheet using loadComponentFromURL().
Rem But the OpenDocument() from the Tools library does it better.
Rem Therefore, we load the Tools library:
GlobalScope.BasicLibraries.LoadLibrary("Tools")
Rem Convert the full path to the file, received in the parameter,
Rem into the correct URL:
sPath = ConvertToURL(sSourcePath)
Rem If a file with that name exists (and it may not exist):
If FileExists(sPath) Then
Rem Open spreadsheet:
oDoc = OpenDocument(sPath,loadComponentProperties)
Rem Recalculate all formulas (and update external links at the same time)
oDoc.calculateAll()
Rem Save:
oDoc.store()
Rem and close
oDoc.close(True)
EndIf
End Sub
(Of course, you can delete the comments, I inserted them to explain what exactly the script should do)
Now if you execute
"C:\Program Files\LibreOffice\program\soffice.exe" --headless --nologo "macro:///UpdateRefs.UpdateHidden.updateAndSave(C:\TEMP\myTestFile.ods)
from the command line you will get the desired result.