Insert a BMP image to a Calc
Posted: Tue Jul 26, 2011 9:38 am
Dear all,
I am adding an image to a calc file from vb application and set original size by using the following code. it works fine for EMF type images. But, it does not work for .BMP files. It inserts an image, but it does not set the original size.
Does any one know the solution for this issue ?
Thanks in Advance.
Regards,
Manikandan
I am adding an image to a calc file from vb application and set original size by using the following code. it works fine for EMF type images. But, it does not work for .BMP files. It inserts an image, but it does not set the original size.
Does any one know the solution for this issue ?
Code: Select all
Dim oSM As Object
Dim oDesk As Object
Dim oDoc As Object
Dim oSheet As Object
Dim arg()
Dim oText As Object
Dim oGraph As Object, oCursor As Object, DrawPages As Object
Dim DrawPage As Object, FileURL As String
Set oSM = CreateObject("com.sun.star.ServiceManager")
Set oDesk = oSM.createInstance("com.sun.star.frame.Desktop")
Dim sSize As Object
Dim sPoint As Object
Set sSize = oSM.Bridge_GetStruct("com.sun.star.awt.Size")
Set sPoint = oSM.Bridge_GetStruct("com.sun.star.awt.Point")
sPoint.X = 0
sPoint.Y = 0
sSize.Width = 15500
sSize.Height = 15500
Set oDoc = oDesk.loadComponentFromURL("private:factory/scalc", "_blank", 0, arg())
Set oSheet = oDoc.Sheets.getByIndex(0)
Set oGraph = oDoc.createInstance("com.sun.star.drawing.GraphicObjectShape")
ImagefilePath="d:\sample.bmp"
FileURL = ConvertToUrl(ImagefilePath)
With oGraph
.GraphicURL = FileURL
.Size = sSize
.Position = sPoint
End With
Set DrawPage = oSheet.DrawPage
Call DrawPage.Add(oGraph)
oGraph.setSize (oGraph.Graphic.Size100thMM)
Regards,
Manikandan