# Insert linked image from file A to file B using object reference to image in file A

I have an A.odt file writer with many embedded images. Via macro I created a reference first to file A and from this to the required image. The structure of the macro used (work) is

sPathFull = "file: ///media/......./filename.odt '.... fullpath of file A
Dim Props (0) As New com.sun.star.beans.PropertyValue
Props (0) .Name = "Hidden"
Props (0) .value = true 'also works with false
oDoc = starDeskTop.loadComponentFromURL (sPathFull, "_Blank", 0, props)
oImg = oDoc.graphicObjects.getByName ( "Image1")


Once the reference oImg is known, it can be used to insert a linked image in a B.odt file writer without extracting the required image in a directory from which to perform the link ? Strangely, oImg,.GraphicURL is null, oImg was a jpg image ( LO type= com.sun.star.text.TextGraphicObject)

The solutions found so far, all using macros, are:

1) Insert oImg with embedded image with copy and paste, but it is not a linking

2) Insert a section S0 in A.odt to include the image, and in file B another section S1 linked to S0 (a possible but complicated solution if to be repeated on other images)

EDIT 3) insert an hyperlink (URL = file:///media/...filename.odt#image2|graphic (but image is visible only after clicking and source file is to open

Libreoffice 6.2.6.2, Ubuntu 16.04

edit retag close merge delete