Category: OpenOffice

Setting the first line as the file name in LibreOffice

LibreOffice Logo

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:

 

  Sub FirstLineFileName_Writer
    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.
    oTC.gotoNextParagraph(false)
    Wend
    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.
    filename = oVC.String
    url = ConvertToURL("C:\" & filename & ".odt")'Insert Your Desired Directory Path.
    oDoc.StoreAsURL(url,Array())
    oVC.gotoRange(Mark,false) 'return view cursor to original position.
    oDoc.Modified = false 'avoid Save being called if doc closed without further edits.
    End 'end normal execution.
    EH: 'error handler.
    MsgBox "You may have illegal file name characters in the first line." & Chr(13)_
    & Chr(13) & filename,,"AN ERROR OCCURRED"
    End Sub

 

This code is used to save the text file by taking the first line of text and setting it as the name. You can edit the directory of the save. Please note that it saves without conformation!

 

Tools > Macros > Organize > Macros >LibreOffice >Basic

Opening the macro menu

New to add a new macro.

 

Adding a new macro

 

Run Macro then choose the macro manually from the menu. But that’s not too handy, is it?

Customizing the key combination

Go to LibreOffice writer and navigate to the menu: Tools > Customize > Tab: Keyboard.

Delete whatever is on CTRL + S, and assign it to the new macro by looking for it, and if everything went according to plan. It should save the 1st line as a file name.

Checkout this for more information.

Important notice

If you get errors it’s because the directory isn’t correct. Libreoffice will default to C:\ and when it can’t save in it. It will crash the macro. I edited the code to: “D:\Documents\ but make sure to choose your own folder.

Apache OpenOffice vs LibreOffice .. I madeup my mind!!

Hey you guys 🙂

I have been reading articles all over the web and testing the new LibreOffice since I published my post two days ago, I must say: I’m very impressed!!



Every objection I had on LibreOffice was gone! Everything about this version is so right!
I’m not talking about the appearance. That’s obvious!

I’m talking about all the work the guys at the document foundation did “Under the hood”, it’s really something! I can totally feel the over all changes ..

I’ve just uninstalled Apache OpenOffice after a five year run (started with OpenOffice of course ) , it was good while it lasted 🙁

I think the guys at the Apache foundation lost the track on OpenOffice, it’s not the same product as it used to be!
I’ve had some stops here in this blog with Apache OpenOffice, like when I wanted it as a the default word processor for Ubuntu 13.04, and when that transparency bug was driving me crazy!! And my utter joy when I got it fixed!

I can’t believe how happy I was when Apache OpenOffice 4.0.0 was out! And the frustration I had when the download broke at 99%!!

I felt like the first time when I used OpenOffice, that overwhelming feeling you only get with true freedom!!

As sad as it may seem. It’s time to move on ..
In sense, it’s not really moving away, it’s actually going back to the roots! Having a truly free and open source word processor for all of your daily needs ..

I’m a LibreOffice guy now 🙂

I’ve decided to download the last OpenOffice version before the Oracle acquire, for memories sake that’s all ..

One last thing .. Could someone tell me how to change the green color scheme? I’d be really happy without it :p
Have a nice day. I can’t wait your feedback on the whole post and the green scheme bit 😉