Hello Stefano,

On Wednesday 26 August 2009, 04:18, Advice Communication wrote:
> Hi Expert,
>
> I would to know If is it possible to create a macro that :
>
> Save in odp format (ex: 1.opd)
>
> And
>
> Export in jpg format (ex: 1.jpg)
>
> In the same time.

You can export page by page to image format, something like:


Option Explicit

Sub ExportODP2PNG
        Dim FOLDER_NAME$
        FOLDER_NAME = "impress_export_demo"

        GlobalScope.BasicLibraries.loadLibrary("Tools")
        Dim oDoc as Object
        oDoc = ThisComponent
        
        If HasUnoInterfaces(oDoc, "com.sun.star.lang.XServiceInfo") Then
                If NOT oDoc.supportsService(_
                        "com.sun.star.presentation.PresentationDocument") Then
                        Exit Sub
                End If
        Else
                Exit Sub
        End If
        
        Dim sBaseURL$
        If oDoc.hasLocation() Then
                sBaseURL = DirectoryNameoutofPath(oDoc.getURL(), "/")
        Else
                sBaseURL = getTempDir() + "/" + FOLDER_NAME
        End If
        
        Dim oExporter
        oExporter = CreateUnoService("com.sun.star.drawing.GraphicExportFilter")
        
        Dim oDrawPages as Object
        oDrawPages = oDoc.getDrawPages()
        
        Dim oDrawPage as Object
        Dim aProps(1) as New com.sun.star.beans.PropertyValue
        aProps(0).Name = "MediaType"
        aProps(0).Value = "image/png"
        aProps(1).Name = "URL"
        
        Dim n&
        For n = 0 To oDrawPages.getCount()-1
                oDrawPage = oDrawPages.getByIndex(n)
                aProps(1).Value = sBaseURL + "/images/" + CStr(n) + ".png"
                oExporter.setSourceDocument(oDrawPage)
                oExporter.filter(aProps)
        Next
        
        If oDoc.hasLocation() and NOT oDoc.isReadonly() Then
                oDoc.store()
        Else
                oDoc.storeAsURL(sBaseURL + "/" + FOLDER_NAME + ".odp", Array())
        End If
End Sub

Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to