One of the few features I missed moving from Microsoft Office was the auto name upon save, where Word takes the first line of the text and uses it to name the text file. LibreOffice (and OpenOffice before that) don’t have this feature! It’s a small thing but over time it becomes a growing nuisance!
Luckily there is an easy fix for that! Which enables you to enjoy the luxury of easy naming of files and limit the Untitled flood over time!
We are going to use a feature known as macros. macros in office are a Visual Basic code that is used to preform a certain task over and over and is triggered by an event. In this post I’ll be showing how to create a macro that saves the file using the first line of text when pressing the key combination of CTRL + S (assigning the macro to save or save as will result in two files: untitled and the first line of text!) So at first, we are going to need our macro. I took this code as is from an OpenOffice form, it works fine without editing:
On Error goto EH
oDoc = ThisComponent
oVC = oDoc.CurrentController.getViewCursor
Mark = oDoc.Text.CreateTextCursorByRange(oVC)’mark position of view cursor.
oTC = oDoc.Text.CreateTextCursor ‘created at the beginning of doc.
While oTC.isEndOfParagraph ‘skip empty paragraphs.
oVC.gotoRange(oTC,false) ‘a text cursor can’t go to the end of a line
oVC.gotoEndOfLine(true) ‘so we have to use the view cursor.