@Ulli_Wue I don’t have a complete answer for you but a partial. Here is the the code to insert an Ole object of type spreadsheet into a writer document:
sub oleexample
oDoc = ThisComponent
txt=oDoc.getText
obj = oDoc.createInstance("com.sun.star.text.TextEmbeddedObject")
obj.CLSID = "47BBB4CB-CE4C-4E80-a591-42d9ae74950f"
obj.attach(ThisComponent.currentController().Selection.getByIndex(0))
oXEO = obj.ExtendedControlOverEmbeddedObject
oXEO.doVerb(0)
end sub
This inserts the spreadsheet at the current cursor location. Like you, I couldn’t find much on the subject. I had absolutely no luck with finding a method for the link (even using Mri ran into a lot of brick walls). Didn’t want to waste the code so I’m posting it to give you another step forward. If I do find anything on the “link” function I will post back.
Edit 12/10/2017:
It has been a while but I been able to apply a link to the spreadsheet created above. This is NOT an OLE object as requested but can be made to appear the nearly the same. The major difference is all sheets must be set individually in code and you cannot update the source from this object. Here is the revised code:
Option Explicit
Sub LinkedSheet
Dim oDoc as Object
Dim oEmbeddedObject as Object
Dim oEmbeddedObjects as Object
Dim oEmbeddedSheet as Object
Dim obj as Object
Dim oXEO as Object
Dim oEOsheet as Object
Dim oCA as Object
Dim oAreaLinks as Object
Dim oSheetLink as Object
oDoc = ThisComponent
oEmbeddedObjects = ThisComponent.getEmbeddedObjects()
If oEmbeddedObjects.hasByName("mySheet") Then
oEmbeddedSheet = oEmbeddedObjects.getByName("mySheet")
oEmbeddedSheet.dispose()
EndIf
obj = oDoc.createInstance("com.sun.star.text.TextEmbeddedObject")
obj.CLSID = "47BBB4CB-CE4C-4E80-a591-42d9ae74950f"
obj.Name = "mySheet"
obj.attach(ThisComponent.currentController().Selection.getByIndex(0))
oXEO = obj.ExtendedControlOverEmbeddedObject
oXEO.doVerb(0)
oXEO.changeState(3)
oEmbeddedObjects = ThisComponent.getEmbeddedObjects()
oEOsheet = oEmbeddedObjects.getByName("mySheet")
oEmbeddedObject = oEOsheet.getEmbeddedObject()
oCA = createUnoStruct("com.sun.star.table.CellAddress")
oCA.Sheet = 0
oCA.Column = 0
oCA.Row = 0
oEmbeddedObject.AreaLinks.insertAtPosition(oCA,"file:///home/YOUR_DIRECTORY/YOUR_SHEET.ods","AREAorRANGE","calc8", "")
oAreaLinks = oEmbeddedObject.AreaLinks
oSheetLink = oAreaLinks.getByIndex(0)
oSheetLink.RefreshPeriod = 75
End Sub
The embedded spreadsheet is given a name (‘mySheet’ used here) and checked early if exists. If so the old one is deleted. Once the sheet object is inserted the link is established in ‘AreaLinks’. To create, use the URL for the spreadsheet and area or RangeName to be linked. The final step gets that link (Index is used but by name available) and sets the refresh period (in seconds). So every X seconds the data will be updated from the SAVED original.