Page 1 of 1

[Solved] Insert Image, Position and Resize via Macro in Calc

Posted: Wed Jan 27, 2016 1:17 am
by masc145
We need to extract certain info create a new spreadsheet format, insert an image and save as pdf
but we can haven“t found how to resize and position the image
we insert it with:

Code: Select all

document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------
dim args1(2) as new com.sun.star.beans.PropertyValue
args1(0).Name = "FileName"
args1(0).Value = "logosLMF.png"
args1(1).Name = "FilterName"
args1(1).Value = "PNG - Portable Network Graphic"
args1(2).Name = "AsLink"
args1(2).Value = false

dispatcher.executeDispatch(document, ".uno:InsertGraphic", "", 0, args1())
and then how do we place it and position: x=0.53cm and y=0.41cm and size: width=15.59cm and heigh=2.83 cm
Any One?
Thanks

Re: Inserting Image, Positioning and Resizing via Macro in C

Posted: Wed Jan 27, 2016 3:41 am
by FJCC
I would insert an image in the first sheet of the document like this

Code: Select all

Folder = "C:\Users\fjcc\Desktop\"

imagen = "W21_0.TIF"
ImagenURL = convertToURL(Folder & imagen)
oImagen_obj = ThisComponent.createInstance("com.sun.star.drawing.GraphicObjectShape")

oImagen_obj.GraphicURL = ImagenURL
oSize = oImagen_obj.Size
oSize.Height = 3000
oSize.Width = 3000
oImagen_obj.Size = oSize
oPos = oImagen_obj.Position
oPos.X = 2000
oPos.Y = 3000
oImagen_obj.Position = oPos

oDP = ThisComponent.DrawPages.getByIndex(0)
oDP.add(oImagen_obj)

Re: Inserting Image, Positioning and Resizing via Macro in C

Posted: Wed Jan 27, 2016 3:56 am
by masc145
it worked, thanks

Re: Inserting Image, Positioning and Resizing via Macro in C

Posted: Wed Jan 27, 2016 5:47 pm
by mauriciobaeza
You can try EasyDev, too: http://easydev.readthedocs.org/en/lates ... sert-image

Best regards

Re: Inserting Image, Positioning and Resizing via Macro in C

Posted: Wed Jan 27, 2016 8:13 pm
by musikai
@mauriciobaeza
Macros created using EasyDev, do they need EasyDev installed when executing?

Re: Inserting Image, Positioning and Resizing via Macro in C

Posted: Thu Jan 28, 2016 4:31 am
by mauriciobaeza
musikai wrote:@mauriciobaeza
Macros created using EasyDev, do they need EasyDev installed when executing?
Yes, It need...

Re: Inserting Image, Positioning and Resizing via Macro in C

Posted: Thu Jan 28, 2016 10:16 pm
by musikai
Thank you!