Macro to load and run ppt for impress

Andrew Douglas Pitonyak andrew at pitonyak.org
Wed Jul 8 16:52:38 PDT 2015


This does work for me, but, only if I define some global variables in 
the defining module. Try setting OptionExplicit at the top of the module 
and it will flag all of those undefined variables for you.

Global oGlob
GLobal oListener
Global boFinished
Global url



On 07/06/2015 04:54 PM, Jerry Geis wrote:
>
> Sub Load(arg as String)
>
> 'register a global event listener, because
> 'we have to wait until loading has finished
> oGlob = CreateUnoService("com.sun.star.frame.GlobalEventBroadcaster")
> oListener = 
> CreateUnoListener("EvList_","com.sun.star.document.XEventListener")
> oGlob.addEventListener(oListener)
> boFinished = false
>
> 'hide the document while loading so that we do not see the loading window
> Dim aProps(2) as new com.sun.star.beans.PropertyValue
> Dim oDoc as Object
> aProps(0).Name  = "Hidden"
> aProps(0).Value = true
> aProps(1).Name  = "ReadOnly"
> aProps(1).Value = true
> url = arg
> oDoc = StarDesktop.loadComponentFromURL(url, "_default", 0, aProps)
>
> 'wait until loading has finished
> while (not boFinished)
> wait(5)
> wend
>
> oGlob.removeEventListener(oListener)
>
> 'loading is done, set the presentation parameters
> oDoc.Presentation.Pause = 0
> 'show the window now as presentation cannot be started
> '(segmentation faults) if it is not
> oDoc.CurrentController.Frame.ContainerWindow.Visible = true
> oDoc.CurrentController.Frame.ContainerWindow.setVisible(false)
> 'start the presentation
> oDoc.Presentation.Start
>
> End Sub
>
> Sub EvList_notifyEvent( o as object )
> if o.EventName = "OnLoadFinished" then
> if url = o.Source.Location then
> boFinished = true
> endif
> endif
>
> End Sub
>
> Sub EvList_disposing()
> End Sub

-- 
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
Info:  http://www.pitonyak.org/oo.php

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20150708/c7094607/attachment.html>


More information about the LibreOffice mailing list