Hello,
I am trying to implement in BASIC :
1. open an impress document
2. add a slide
3. add a text on the slide
4. import a picture to the same slide
Thank you
Open Impress doc, add slide, add text, import picture
-
- Posts: 2
- Joined: Sat Mar 02, 2019 8:50 pm
Open Impress doc, add slide, add text, import picture
OpenOffice 6.1.4.2 on WINDOWS 10
Re: impress basic
Here's a start for 1:
viewtopic.php?f=20&t=17075
You may find the documentation here helpful:
https://www.pitonyak.org/oo.php
viewtopic.php?f=20&t=17075
You may find the documentation here helpful:
https://www.pitonyak.org/oo.php
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
- Jurassic Pork
- Posts: 24
- Joined: Wed Oct 25, 2017 7:55 am
- Location: France
Re: impress basic
hello,
here is an example to do what you want to do :
tested with Impress LibreOffice 6.4.7.2. Should work with OpenOffice.
Friendly, J.P
hello,Pierre.Godot wrote:Hello,
I am trying to implement in BASIC :
1. open an impress document
2. add a slide
3. add a text on the slide
4. import a picture to the same slide
Thank you
here is an example to do what you want to do :
Code: Select all
Sub TestPierre()
Dim oPresDoc,oSlideList,oSlide,TxtShp,oImagen_obj,oPos,oSize as object
Dim TxtPoint as New com.sun.star.awt.Point
Dim FileName as string
Dim noArgs() 'An empty array for the arguments.
FileName = "D:\Temp\testPierre.odp"
FileName = convertToURL(FileName)
oPresDoc = StarDesktop.loadComponentFromURL(FileName, "_blank", 0, noArgs())
'get list of slides
oSlideList = oPresDoc.getDrawPages()
oSlideList.insertNewByIndex(oSlideList.getCount()) ' create new slide
oSlide = oSlideList.getByIndex(oSlideList.getCount()-1) ' select new slide
oSlide.setName("myNewSlide") ' name new slide
Set TxtShp = oPresDoc.createInstance("com.sun.star.drawing.TextShape") ' create new TextShape
oSlide.Add(TxtShp) ' insert the new TextShape in the new slide
TxtPoint.X = OSlide.Width * 0.1
TxtPoint.Y = OSlide.Height * 0.1
TxtShp.Position = TxtPoint
TxtShp.TextHorizontalAdjust = com.sun.star.drawing.TextHorizontalAdjust.LEFT
TxtShp.TextAutoGrowWidth = false
TxtShp.TextAutoGrowHeight = false
TxtShp.SetString("Here is Babe the Sheep-Pig")
oSize = TxtShp.Size
oSize.Height = 2000
oSize.Width = 23000
TxtShp.Size = oSize
TxtShp.TextFitToSize = com.sun.star.drawing.TextFitToSizeType.PROPORTIONAL
ImagenURL = convertToURL("d:\temp\babe-pig.jpg")
' create new GraphicObjectShape
oImagen_obj = ThisComponent.createInstance("com.sun.star.drawing.GraphicObjectShape")
oImagen_obj.GraphicURL = ImagenURL
oSize = oImagen_obj.Size
oSize.Height = 8000
oSize.Width = 6000
oImagen_obj.Size = oSize
oPos = oImagen_obj.Position
oPos.X = 10000
oPos.Y = 5000
oImagen_obj.Position = oPos
oSlide.add(oImagen_obj) ' insert the new GraphicObjectShape in the new slide
End Sub
Friendly, J.P
OpenOffice 4.1.14 , LibreOffice 7.6.2.1 on Windows 11/ LibreOffice 7.3.7 on Lubuntu 22.04