I have a problem when I try to put a picture inside a Writer document with Delphi.
I get an error message "The Variant does not contain an Object type" at the level of the line monImage.Position:= positionImage;
When I remove that line the picture is placed on the page but I try to put it at the right location.
I can read the values (X & Y) of positionImage.
So I do not understand where is the problem.
Code: Select all
Procedure Insert_Picture(File_Name: String);
Var
monImage, positionImage: Variant;
begin
myCursor.gotoNextParagraph(False);
positionImage:= CreateUnoStruct('com.sun.star.awt.Point',0);
positionImage[0].X:= 4000;
positionImage[0].Y:= 4000;
monImage:= MyDocument.createInstance('com.sun.star.drawing.GraphicObjectShape');
monImage.GraphicURL:= ConvertToURL(File_Name);
monImage.AnchorType:= 0;
myText.insertTextContent(myCursor, monImage, false);
resizeImageByDPI(monImage, 5500);
-----> monImage.Position:= positionImage; <------------
end;
end;Thank you.
Benoît