[Gelöst] Bild/Grafik einfügen in Calc über Zelladresse
Verfasst: Mi, 20.04.2011 11:41
Hey, ich habe es geschafft.
Hier habt Ihr mal die Möglichkeit, eine Grafik in Calc einzufügen.
Mit dieser Methode wird aufgrund der Celladresse die XY Position ermittelt und dann die Grafik eingefügt.
Hier habt Ihr mal die Möglichkeit, eine Grafik in Calc einzufügen.
Mit dieser Methode wird aufgrund der Celladresse die XY Position ermittelt und dann die Grafik eingefügt.

Code: Alles auswählen
Sub GrafikEinfuegen
Dim Page As Object
Dim GraphicObjectShape As Object
Dim Point As New com.sun.star.awt.Point
Dim Size As New com.sun.star.awt.Size
mycell = oSheet.getCellByPosition(Letztespalte,0)
oColumn = mycell.getColumns.getByIndex(0).getName()
cellname = oColumn
cellname = cellname & 1
'oDoc muss natürlich definiert werden!
oCell = oDoc.sheets.getByName("Angebot").getCellRangeByName(cellname)
aPos = oCell.Position
Point.x = aPos.X-1900
Point.y = aPos.Y
Size.Width = 5460
Size.Height = 2000
Page = oDoc.drawPages(0)
GraphicObjectShape = oDoc.createInstance("com.sun.star.drawing.GraphicObjectShape")
GraphicObjectShape.Size = Size
GraphicObjectShape.Position = Point
GraphicObjectShape.GraphicURL = "file:///Z:/Programme/Vorlagen für Makros/Bilder/SW.jpg"
GraphicObjectShape.Name = "Name"
GraphicObjectShape.Title = "Name"
GraphicObjectShape.GraphicColorMode = com.sun.star.drawing.ColorMode.STANDARD
Page.add(GraphicObjectShape)
End Sub