Page 1 of 1

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

PostPosted: Tue Dec 05, 2017 10:28 am
by mgp
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

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

PostPosted: Tue Dec 05, 2017 5:32 pm
by John_Ha
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.

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

PostPosted: Tue Dec 05, 2017 9:23 pm
by FJCC
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.

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

PostPosted: Tue Dec 05, 2017 11:32 pm
by mgp
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