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

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
masc145
Posts: 2
Joined: Wed Jan 27, 2016 1:09 am

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

Post 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
Last edited by Hagar Delest on Fri Feb 26, 2016 11:19 pm, edited 1 time in total.
Reason: tagged [Solved].
OpenOffice 4.0.1 with MacOs 10.11.2
FJCC
Moderator
Posts: 9543
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

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

Post 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)
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
masc145
Posts: 2
Joined: Wed Jan 27, 2016 1:09 am

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

Post by masc145 »

it worked, thanks
OpenOffice 4.0.1 with MacOs 10.11.2
mauriciobaeza
Posts: 56
Joined: Thu Apr 22, 2010 5:03 am

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

Post by mauriciobaeza »

You can try EasyDev, too: http://easydev.readthedocs.org/en/lates ... sert-image

Best regards
______________________________________________
Everything not given is lost
AOO 4.1 / LibO 4.3 on ArchLinux with Gnome3
Please, I do not answer private questions, you use the forum
musikai
Volunteer
Posts: 294
Joined: Wed Nov 11, 2015 12:19 am

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

Post by musikai »

@mauriciobaeza
Macros created using EasyDev, do they need EasyDev installed when executing?
Win7 Pro, Lubuntu 15.10, LO 4.4.7, OO 4.1.3
Free Project: LibreOffice Songbook Architect (LOSA)
http://struckkai.blogspot.de/2015/04/li ... itect.html
mauriciobaeza
Posts: 56
Joined: Thu Apr 22, 2010 5:03 am

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

Post by mauriciobaeza »

musikai wrote:@mauriciobaeza
Macros created using EasyDev, do they need EasyDev installed when executing?
Yes, It need...
______________________________________________
Everything not given is lost
AOO 4.1 / LibO 4.3 on ArchLinux with Gnome3
Please, I do not answer private questions, you use the forum
musikai
Volunteer
Posts: 294
Joined: Wed Nov 11, 2015 12:19 am

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

Post by musikai »

Thank you!
Win7 Pro, Lubuntu 15.10, LO 4.4.7, OO 4.1.3
Free Project: LibreOffice Songbook Architect (LOSA)
http://struckkai.blogspot.de/2015/04/li ... itect.html
Post Reply