| View previous topic :: View next topic |
| Author |
Message |
RogerWilco Newbie

Joined: 24 Jul 2005 Posts: 3
|
Posted: Wed Aug 03, 2005 10:14 pm Post subject: ASCII filter on document load |
|
|
Hey everyone.
I'm really stuck here. There are certain documents I am trying to open that only have linefeeds instead of CR+LF. This seems to gum up the OpenOffice Macro because it wants to know the ASCII Filter type when opening the document. How can I specify this in a macro? Here is what my macro currently looks like. Pretty much all of it was taken from examples here (Thanks guys!):
Sub Main(a As String, b As Integer, c As String)
oDoc = StarDesktop.loadComponentFromURL( ConvertToURL( c ), "_blank", 0, Array() )
oDoc.setPrinter(Array(MakePropertyValue( "Name", a) ) )
oDoc.print(Array(MakePropertyValue( "CopyCount", b ),MakePropertyValue( "Pages", "1" ),MakePropertyValue( "Wait", true ) ) )
oDoc.close( True )
StarDesktop.terminate()
End Sub
Function MakePropertyValue( Optional cName As String, Optional uValue ) As com.sun.star.beans.PropertyValue
oPropertyValue = createUnoStruct( "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
Can anyone offer any help?
Thanks! |
|
| Back to top |
|
 |
ms777 Super User


Joined: 07 Feb 2004 Posts: 1355
|
Posted: Wed Aug 03, 2005 11:47 pm Post subject: |
|
|
If all of the documents, you want to import, need the same filter, you can set the filter by passing a MediaDescriptor to loadComponentFromUrl. See the following snippet, which forces calc to load as CSV:
| Code: | function loadCSVfromURL(sUrl as String, sFilter as String, bHidden as Boolean) as Object
Dim aProps(1) As New com.sun.star.beans.PropertyValue
aProps(0).Name = "FilterName"
aProps(0).Value = "Text - txt - csv (StarCalc)"
aProps(1).Name = "FilterOptions"
aProps(1).Value = sFilter
loadCSVfromURL = StarDesktop.loadComponentFromURL(sUrl, "_blank", 0, aProps())
end function
| For a list of available filters see e.g. http://www.oooforum.org/forum/viewtopic.phtml?t=3549
If, however, you want to load documents with different filters, and only some of the filters require additional arguments, you have to determine the document type before loadComponentFromUrl. See http://www.oooforum.org/forum/viewtopic.phtml?p=80918#80918 as a code example
ms777 |
|
| Back to top |
|
 |
RogerWilco Newbie

Joined: 24 Jul 2005 Posts: 3
|
Posted: Thu Aug 04, 2005 1:18 am Post subject: |
|
|
Thanks!
I'll try playing around with this. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|