'thanks to DannyB from http://www.oooforum.org/forum/ for this idea and code 'distributed under the terms of GNU Affero General Public License (AGPL) (c) eyeOS 2007-2008 Sub ConvertAny(cFile,newName,myFilter) On Error Resume Next cURL = ConvertToURL( cFile ) oDoc = StarDesktop.loadComponentFromURL( cURL, "_blank", 0, Array(_ MakePropertyValue( "Hidden", True ),_ ) ) cURL = ConvertToURL( newName ) oDoc.storeToURL( cURL, Array(_ MakePropertyValue( "FilterName", myFilter ),_ ) oDoc.close( True ) End Sub Sub SplitSlides( cImpressDocToSplit, newName ) On Error Resume Next ' Open the document to find out how many pages it has. oDoc = StarDesktop.LoadComponentFromURL( ConvertToURL( cImpressDocToSplit ), "_blank", 0, Array(MakePropertyValue( "Hidden", True )) ) nNumPages = oDoc.getDrawPages().getCount() ' Now that we know how many pages it has, close it. oDoc.close( True ) ' Now loop once for each page. nHighestPageNumber = nNumPages-1 ' nPageToSave = 2 For nPageToSave = 0 To nHighestPageNumber ' Open the document. oDoc = StarDesktop.LoadComponentFromURL( ConvertToURL( cImpressDocToSplit ), "_blank", 0, Array(MakePropertyValue( "Hidden", True )) ) ' Delete all pages except the one we're interested in keeping ' on this loop. DeleteAllPagesExcept( oDoc, nPageToSave ) ' Save it as a JPEG. oDoc.storeToUrl( ConvertToURL( newName + "_" + nPageToSave + ".png" ), _ Array( MakePropertyValue( "FilterName", "impress_png_Export" ) ) ) ' Close the document without saving it. oDoc.close( True ) Next End Sub Sub getSingleSlide(cName,myNumber,newName) On Error Resume Next oDoc = StarDesktop.LoadComponentFromURL( ConvertToURL( cName ), "_blank", 0, Array(MakePropertyValue( "Hidden", True )) ) nNumPages = oDoc.getDrawPages().getCount() ' Delete all pages except the one we're interested in keeping ' on this loop. Dim cNumber as Integer cNumber = myNumber If cNumber < nNumPages Then DeleteAllPagesExcept( oDoc, cNumber ) ' Save it as a JPEG. oDoc.storeToUrl( ConvertToURL( newName + "_" + myNumber + ".png" ), _ Array( MakePropertyValue( "FilterName", "impress_png_Export" ) ) ) ' Close the document without saving it. EndIf oDoc.close( True ) End Sub Function DeleteAllPagesExcept( oDoc, nPageToKeep ) On Error Resume Next nNumPages = oDoc.getDrawPages().getCount() nHighestPageNumber = nNumPages-1 ' Delete the last page, then the page before that, ' then the page before that, until we get to the ' page to keep. ' This deletes all pages AFTER the page to keep. nPageToDelete = nHighestPageNumber Do while nPageToDelete > nPageToKeep ' Get the page. oPage = oDoc.getDrawPages().getByIndex( nPageToDelete ) ' Tell the document to remove it. oDoc.getDrawPages().remove( oPage ) nPageToDelete = nPageToDelete - 1 Loop ' Delete all the pages before the page to keep. For i = 0 To nPageToKeep - 1 ' Delete the first page. nPageToDelete = 0 ' Get the page. oPage = oDoc.getDrawPages().getByIndex( nPageToDelete ) ' Tell the document to remove it. oDoc.getDrawPages().remove( oPage ) Next End Function Function MakePropertyValue( Optional cName As String, Optional uValue ) As com.sun.star.beans.PropertyValue On Error Resume Next Dim oPropertyValue As New com.sun.star.beans.PropertyValue If Not IsMissing( cName ) Then oPropertyValue.Name = cName EndIf If Not IsMissing( uValue ) Then oPropertyValue.Value = uValue EndIf MakePropertyValue() = oPropertyValue End Function