Jump to content

Macros/Basic/Calc/Images

From The Document Foundation Wiki
This page contains changes which are not marked for translation.


Return to Index

Images in Calc

Insert an image from a .png file

Sub InsertImage()
    Dim oGraph As Object

    oGraph = thisComponent.createInstance("com.sun.star.drawing.GraphicObjectShape")
    oGraph.GraphicURL =  ConvertToUrl( "/someDir/d1/d2/someFile.png")
    thisComponent.CurrentController.ActiveSheet.getDrawPage().add(oGraph)

    Dim oSize
    Dim oPos
	oSize = oGraph.Size
    oSize.Height = 3000
    oSize.Width = 5000
    oGraph.setsize(oSize)

    oPos = oGraph.position
    oPos.x = 2000
    oPos.y = 2000
    oGraph.position = oPos
End sub