[Solved] Macro to change slide format from 4:3 to 16:9

Discuss the presentation application

[Solved] Macro to change slide format from 4:3 to 16:9

Postby mgp » Tue Dec 05, 2017 10:28 am

I am using the code below to create a new presentation with a blank slide. It works well but the slide defaults to 4:3 format. What should I add to the code to create or convert the slide into 16:9 format?
Thank you!

Code: Select all   Expand viewCollapse view
Dim Dummy()
Dim Url As String
Dim outDoc, outView, outSlides As Object

' Create blank presentation
Url = "private:factory/simpress"
outDoc = StarDesktop.loadComponentFromURL(Url, "_blank", 0, Dummy())
   outView = outDoc.getCurrentController()
   outSlides = outDoc.DrawPages
Last edited by mgp on Tue Dec 05, 2017 11:34 pm, edited 1 time in total.
OpenOffice 2.4 on Fedora 26
mgp
 
Posts: 2
Joined: Tue Dec 05, 2017 10:10 am

Re: Macro to change slide format from 4:3 to 16:9

Postby John_Ha » Tue Dec 05, 2017 5:32 pm

Welcome to the forum.

Format > Page ..., and set what you want before running the macro. From memory, Format > Page cannot be recorded into a macro.

You may be better searching the Macros and UNO API forum with format page for posts like First macros for page formatting.

If your problem is solved please view your first post in this thread and click the Edit button (top right in the post) and add [Solved] in front of the subject.
LO 6.4.4.2, Windows 10 Home 64 bit

See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
John_Ha
Volunteer
 
Posts: 7831
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

Re: Macro to change slide format from 4:3 to 16:9

Postby FJCC » Tue Dec 05, 2017 9:23 pm

Try changing the Height and Width of the first DrawPage
Code: Select all   Expand viewCollapse view
  oDrawPages = ThisComponent.getDrawPages()
  oObj1 = oDrawPages.getByIndex(0)
  oObj1.Height = 22860
 
  oObj1.Width = 40640

The dimensions are in units of 0.01mm, so those two settings are 9 and 16 inches.
Windows 10 and Linux Mint, since 2017
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
FJCC
Moderator
 
Posts: 7789
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Macro to change slide format from 4:3 to 16:9

Postby mgp » Tue Dec 05, 2017 11:32 pm

Thank you! Here is what worked best!
Code: Select all   Expand viewCollapse view
sub setpage16x9
'Changes the current slide format to 16x9.
'It sets page size which is specified in units of 0.01mm.
'Setting it to 40640x22860 (16x9in) is problematic if you merge with slides
' created manually. This is because when you set a page to 16x9 using menus
' it sets to 28002x15752.
  oDrawPages = ThisComponent.getDrawPages()
  oObj1 = oDrawPages.getByIndex(0)
'  oObj1.Height = 22860  '9in in mm * 10
'  oObj1.Width = 40640   '16in in mm * 10
  oObj1.Height = 15752   'default from slide set to 16x9
  oObj1.Width = 28002    'default from slide set to 16x9
end sub
OpenOffice 2.4 on Fedora 26
mgp
 
Posts: 2
Joined: Tue Dec 05, 2017 10:10 am


Return to Impress

Who is online

Users browsing this forum: No registered users and 3 guests