Macro to open a document & read the first line of text

I have a need for a macro to open a document (it could be WORD, OO, LO, text or rtf) most importantly NOT to display it in a frame (I have 1000’s of documents to process) and read the first line of text.

I’ve been reading Andrew Pitonyak excellent (if opaque) useful macro information but can’t find anything useful.

I’m hoping that I can make use of LO’s internals and have ONE macro to process any kind of document.Is that unreasonable?

Any pointers and/or code would be most useful.

Hi - Attached is a sample procedure that meets the strict sense to demand: read the first line (and display). I draw your attention to the fact that it is the first line (not the first sentence or paragraph), and that the program not “loop” to look for the first line containing something.

Sub Main

dim sUrlDoc as string
dim oDoc as object, oCursor as object

dim Prop(0) as new com.sun.star.beans.PropertyValue

Prop(0).Name = "Hidden"
Prop(0).Value = true

sUrlDoc = convertToUrl("C:\Tests\a.odt")

oDoc = StarDesktop.loadComponentFromURL(sUrlDoc, "_blank", 0, Prop() )
oCursor = oDoc.CurrentController.viewCursor
oCursor.gotoStart(false)
oCursor.gotoEndOfLine(true)

msgbox oCursor.string

oDoc.close(true)

End Sub

This great! Thank you very much it’s saved me hours of work.
Doing this with VBA on Windows is much more complicated!

I’ve tested it with LO Version: 4.4.1.2 on my Apple iMac with OS X Yosemite 10.10.2
and it works for:

.docx
.doc
.odt
.txt
.rtf
documents

it doesn’t appear to work for
.rtfd
or TextEdit
documents

Where can I find out more about using

com.sun.star.beans.PropertyValue

please?

css.beans.PropertyValue itself provides nothing of interest here its only a kind of “pack-box” for the Information of Interest ( the pair "Hidden": True in this case)

Information on Hidden here

DLP done great work bug AKAIK not on RTFD, that said, if I’m not mistaken it is a bundle, a folder containing a RTF. So you can unzip…