Macro code to copy contents from a saved slide to current

Discuss the presentation application
Post Reply
powermacro
Posts: 2
Joined: Fri Sep 07, 2018 7:15 pm

Macro code to copy contents from a saved slide to current

Post by powermacro »

I am trying to write a macro that copies the contents (objects, text, etc.) off a single slide in a file saved on the disk, and paste them automatically onto the slide that I am currently editing.

I have an equivalent set of code for Powerpoint, but I'm having difficulty translating this to LibreImpress. In Powerpoint macro basic, the technique would look like this:

oCurrentSlide = ActiveWindow.View.Slide.SlideIndex
...
ActiveWindow.View.GotoSlide (oSlideCopy)
...
Presentations(PPTcount).Slides(oSlideCopy).Shapes.SelectAll
ActiveWindow.Selection.Copy
...
ActiveWindow.View.GotoSlide (oCurrentSlide)
ActiveWindow.View.Paste


I'm wondering if anyone here could help direct me to equivalent functions / methods in OpenOffice / LibreImpress?

Thank you!
LibreOffice 6.0.3.2 on Ubuntu
User avatar
Zizi64
Volunteer
Posts: 11353
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Macro code to copy contents from a saved slide to curren

Post by Zizi64 »

You can control the Writer, Calc, Draw, and Impress applications and the related documents by the usage of the API functions.
You can call them from all of the supported programming languages - for example: from the built-in StarBasic.
API : Application Programming Interface

See Andrew Pitonyak's free macro programming books.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
powermacro
Posts: 2
Joined: Fri Sep 07, 2018 7:15 pm

Re: Macro code to copy contents from a saved slide to curren

Post by powermacro »

Thank you. I just read through the 683 page book here: http://www.pitonyak.org/OOME_4_0.odt - that's an impressive work of documentation.

It would appear that the way I'd need to access these is by the com.sun.star.presentation.Shape method and accessors, which is covered in his section 16.2?

However, the critical function that is needed in the Powerpoint code version is the .Slides() selector that selects a slide by number, and then the .Shapes.SelectAll method. It's not obvious to me that the second method is available in StarBasic?

What I was able to find was in section 11.3, the function example CopyToClipboard_API() but that doesn't show the SelectAll functionality that I would need to call beforehand - it appears to only work on a single object method at a time?
LibreOffice 6.0.3.2 on Ubuntu
Post Reply