PortableApp LO 7.3.1.3 Win10
When I use a Basic macro with the ScriptForge UI service OpenDocument method to open an ods file that has an external link, the link only updates if the file is opened with the method’s Hidden parameter set to False. If set to True, the document opens (hidden of course) but its external link does not update.
Following is a sample macro that shows this behaviour.
First make two documents each having a single external link to source “https:\www.google.com” element “HTML_all” inserted at cell Sheet1.A1. After inserting the link, several cells including A1 will receive data from the link. Clear the value in cell A1 and then save the document, first as C:\Documents\File1WithExternalLink.ods and then again as C:\Documents\File2WithExternalLink.ods. Other than their names, the documents are identical.
In another workbook, make this macro and run it.
Sub OpenDocs
GlobalScope.BasicLibraries.LoadLibrary("ScriptForge")
Dim ui as Object
Set ui = CreateScriptService("UI")
Dim myDoc1 as Object, myDoc2 as Object
'this opens document 1 visible and the link auto-updates (LO options and security are set to allow auto-updating)
Set myDoc1 = ui.OpenDocument("C:\Documents\File1WithExternalLink.ods", hidden:= False)
MsgBox "myDoc1.A1 " & myDoc1.GetValue("A1") 'message shows that A1 has been updated by external link
myDoc1.ClearValues("A1") 'clear the value in A1 to be able to prove that external link worked
myDoc1.Save
myDoc1.CloseDocument
'but this opens document 2 hidden and it does not auto-update
Set myDoc2 = ui.OpenDocument("C:\Documents\File2WithExternalLink.ods", hidden:= True)
MsgBox "myDoc2.A1 " & myDoc2.GetValue("A1") 'message shows that A1 has not been updated by external link
myDoc2.ClearValues("A1") 'clear the value in A1 to be able to prove external link did not work
myDoc2.Save
myDoc2.CloseDocument
ui.Dispose
End Sub
Am I doing something wrong here? Is this expected behaviour? Is there a way I can force the hidden document to update its external link?