OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

ASCII filter on document load

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
RogerWilco
Newbie
Newbie


Joined: 24 Jul 2005
Posts: 3

PostPosted: Wed Aug 03, 2005 10:14 pm    Post subject: ASCII filter on document load Reply with quote

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
View user's profile Send private message
ms777
Super User
Super User


Joined: 07 Feb 2004
Posts: 1355

PostPosted: Wed Aug 03, 2005 11:47 pm    Post subject: Reply with quote

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
View user's profile Send private message
RogerWilco
Newbie
Newbie


Joined: 24 Jul 2005
Posts: 3

PostPosted: Thu Aug 04, 2005 1:18 am    Post subject: Reply with quote

Thanks!

I'll try playing around with this.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
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