Edit: Split from [Writer] Save with first line as file name |
This works really great and helped A LOT !!! I'm mainly dealing with VBA, but have to do it with OO this time, so I'm quite a beginner in this.
I'm trying to modify the code to rename ALL files from a certain folder. My problem is that I cannot assign the NextFile that I get to work with the ThisComponent statement.
So, how can I make the NextFile to be the active file and work with ITS first line?
Here's the code that I have so far:
Code: Select all
Sub FirstLineFileName_Writer
Dim NextFile As String
NextFile = Dir("C:\...\", 0)
While NextFile <> ""
oDoc = ThisComponent
oVC = oDoc.CurrentController.getViewCursor
Mark = oDoc.Text.CreateTextCursorByRange(oVC)
oTC = oDoc.Text.CreateTextCursor
While oTC.isEndOfParagraph
oTC.gotoNextParagraph(false)
Wend
oVC.gotoRange(oTC,false)
oVC.gotoEndOfLine(true)
filename = oVC.String
url = ConvertToURL("C:\" & filename & ".odt")
oDoc.StoreAsURL(url,Array())
oVC.gotoRange(Mark,false)
oDoc.Modified = false
NextFile = Dir
Wend
End Sub