I have the very same problem. I use this code to programmatically export to XLS (gracefully taken from
http://www.xml.com/pub/a/2006/01/11/fro ... ffice.html):
Code: Select all
Sub SaveAsXLS( cFile )
cURL = ConvertToURL( cFile )
' Open the document. Just blindly assume that the document
' is of a type that OOo will correctly recognize and open
' without specifying an import filter.
oDoc = StarDesktop.loadComponentFromURL( cURL, "_blank", 0, _
Array(MakePropertyValue( "Hidden", True ),))
cFile = Left( cFile, Len( cFile ) - 4 ) + ".xls"
cURL = ConvertToURL( cFile )
' Save the document using a filter.
oDoc.storeToURL( cURL, Array(_
MakePropertyValue( "FilterName", "MS Excel 97" ),)
oDoc.close( True )
End Sub
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
Running this (by
Code: Select all
openoffice.org --headless "macro:///Standard.Conversions.SaveAsXLS(/var/tmp/myfile.ods)"
): window freeze gets lost. In contrast, when I run a similar macro from
within OO, window freeze is preserved. Window freeze is also preserved when doing a simple "Save As...", as OP mentioned.
I've now found a solution that keeps the window freeze information, albeit clumsy: Changing the "Hidden" property arg of loadComponentFromURL to "
False" works for me.
The downside is that the conversion takes significantly longer and an OO GUI window opens while the macro is running. It seems like the window freeze information is only respected when there actually
is a window.
I.e.
Code: Select all
Sub SaveAsXLS( cFile )
cURL = ConvertToURL( cFile )
' Open the document. Just blindly assume that the document
' is of a type that OOo will correctly recognize and open
' without specifying an import filter.
oDoc = StarDesktop.loadComponentFromURL( cURL, "_blank", 0, _
Array(MakePropertyValue( "Hidden", False),))
cFile = Left( cFile, Len( cFile ) - 4 ) + ".xls"
...
Someone got a cleaner solution?
Regards,
Holger