Hi All,
I use open office 4 and i use impress to convert ppt to swf. I have about thousand of ppt and have to export it to SWF format. I googled it and found some macros for open office 3 and tried it in open office 4 but it didnt worked. Can please any one suggest way to batch convert ppt to swf using open office 4.
Thank you in advance
Batch Convert PPT & PPTX to SWF
-
- Posts: 3
- Joined: Mon Jan 20, 2014 6:33 am
Batch Convert PPT & PPTX to SWF
Open office 4.0 Windows 7
Re: Batch Convert PPT & PPTX to SWF
If you post the macro code someone may have a suggestion. Macros from version 3 almost always work in version 4, though incompatibility is possible.
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
-
- Posts: 3
- Joined: Mon Jan 20, 2014 6:33 am
Re: Batch Convert PPT & PPTX to SWF
Hi FJCC,
Here is the macro code i got from "http://www.bulahema.com/old/en/openoffi ... conversion"
Here is the macro code i got from "http://www.bulahema.com/old/en/openoffi ... conversion"
Code: Select all
REM ***** BASIC *****
Sub Main(strFile, dirName)
SplitSlides(strFile, dirName)
End Sub
Sub SplitSlides(cImpressDocToSplit, dirName)
' This is the name of the Impress document to split
' into separate documents.
' Each page of this Impress document is saved as a
' separate document, as a PDF, and also as a Flash.
'cImpressDocToSplit = "enterPathManuallyForOverrideHere"
' Open the document to find out how many pages it has.
oDoc = OpenDocument( cImpressDocToSplit )
'Create the XML file for the document titles
myNames = ""
oDrawPages = oDoc.getDrawPages()
'print aSlideNames
' Iterate over each page.
For i = 0 To oDrawPages.getCount() - 1
' Get the page object
oDrawPage = oDrawPages.getByIndex( i )
' Get the slide name
cSlideName = oDrawPage.Name
myNames = myNames+"<slide>"
myNames = myNames+"<title>"
myNames = myNames+cSlideName
'Print cSlideName
myNames = myNames+"</title>"
myNames = myNames+"</slide>"
Next
myNames = myNames+""
iNumber = Freefile
aFile = dirName + cImpressDocToSplit+"_pre.xml"
Open aFile For Output As #iNumber
Print #iNumber, myNames
Close #iNumber
nNumPages = oDoc.getDrawPages().getCount()
' Now that we know how many pages it has, close it.
oDoc.dispose()
' Get the name of the document, but without a filename suffix.
cImpressDocToSplitNoSuffix = Left( cImpressDocToSplit, Len( cImpressDocToSplit ) - 4 )
' Now loop once for each page.
nHighestPageNumber = nNumPages-1
' nPageToSave = 2
For nPageToSave = 0 To nHighestPageNumber
' Open the document.
oDoc = OpenDocument( cImpressDocToSplit )
' Delete all pages except the one we're interested in keeping
' on this loop.
DeleteAllPagesExcept( oDoc, nPageToSave )
' Prepare to save the document in multiple forms.
' First get the new filename to save it under.
'cNewName = cImpressDocToSplitNoSuffix + " -- page " + CSTR( nPageToSave + 1 )
'cNewName = dirName + cImpressDocToSplitNoSuffix + "_" + CSTR( nPageToSave + 1 )
cNewName = dirName + "\slide_" + CSTR( nPageToSave + 1 )
'print "Ouputting to " + cNewName
' Save the document as a new impress document.
oDoc.storeToURL( ConvertToURL( cNewName + ".sxi" ), Array() )
' Save it as a PDF.
'ExportToPDF( oDoc, cNewName )
' Save it as a Flash.
ExportToSWF( oDoc, cNewName )
' Close the document without saving it.
oDoc.dispose()
Next
End Sub
' Pass in the pathname to an Impress document.
' This opens the document, and returns it.
Function OpenDocument( cImpressDoc )
' Open the Impress document.
oDoc = StarDesktop.LoadComponentFromURL( ConvertToURL( cImpressDoc ), "_blank", 0, Array() )
' Return the document
OpenDocument() = oDoc
End Function
' Delete all pages of an Impress or Draw document,
' EXCEPT for a certian page that we want to keep.
Function DeleteAllPagesExcept( oDoc, nPageToKeep )
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
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
Sub ExportToPDF( oDoc, cFilename )
cUrl = ConvertToURL( cFilename + ".pdf" )
oArgs = Array(_
MakePropertyValue( "URL", cURL ),_
MakePropertyValue( "FilterName", "impress_pdf_Export" ),_
)
oController = oDoc.getCurrentController()
oFrame = oController.getFrame()
oDispatcher = createUnoService( "com.sun.star.frame.DispatchHelper" )
oDispatcher.executeDispatch( oFrame, ".uno:ExportTo", "", 0, oArgs() )
End Sub
Sub ExportToSWF( oDoc, cFilename )
cUrl = ConvertToURL( cFilename + ".swf" )
oArgs = Array(_
MakePropertyValue( "URL", cURL ),_
MakePropertyValue( "FilterName", "impress_flash_Export" ),_
)
oController = oDoc.getCurrentController()
oFrame = oController.getFrame()
oDispatcher = createUnoService( "com.sun.star.frame.DispatchHelper" )
oDispatcher.executeDispatch( oFrame, ".uno:ExportTo", "", 0, oArgs() )
'delete the sxi file
kill cFilename + ".sxi"
End Sub
Last edited by FJCC on Mon Jan 20, 2014 8:02 am, edited 1 time in total.
Reason: added code tags FJCC
Reason: added code tags FJCC
Open office 4.0 Windows 7
-
- Posts: 3
- Joined: Mon Jan 20, 2014 6:33 am
Re: Batch Convert PPT & PPTX to SWF
Hi FJCC,
When i execute batch i get an error saying Basic run time error Device I/O error. Pointing to the line
Open aFile For Output As #iNumber.
Can you tell me what is causing the error
When i execute batch i get an error saying Basic run time error Device I/O error. Pointing to the line
Open aFile For Output As #iNumber.
Can you tell me what is causing the error
Open office 4.0 Windows 7
Re: Batch Convert PPT & PPTX to SWF
I can't tell much from the error message alone. I see that
Sub SplitSlides(cImpressDocToSplit, dirName)
is passed a directory name. I expect that in the line
Open aFile For Output As #iNumber
the aFile has to be a URL. What exactly is the value of dirName that the sub is receiving?
Sub SplitSlides(cImpressDocToSplit, dirName)
is passed a directory name. I expect that in the line
Open aFile For Output As #iNumber
the aFile has to be a URL. What exactly is the value of dirName that the sub is receiving?
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Re: Batch Convert PPT & PPTX to SWF
Nope. The following snippet from the F1-help actually works:FJCC wrote:the aFile has to be a URL
Code: Select all
aFile = "c:\data.txt"
iNumber = Freefile
Open aFile For Output As #iNumber
Print #iNumber, "This is a line of text"
Print #iNumber, "This is another line of text"
Close #iNumber
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice