Saturday, March 20, 2010

Optimise OpenOffice.org

OpenOffice.org  is the greatest open source alternative to Microsoft’s Office suite.

Over the years OpenOffice has evolved to become much more than just an alternative to MS Office however.

Let’s look at some hacks that will allow you to become more of a power user of OpenOffice, enabling you to be more productive with the software.OpenOffice Folder


Resources:
OpenOffice (version 3 or higher)
BasicAddonBuilder
Sun PDF Import Extension
Professional Template Pack II – English
Writer’s Tools
OpenOffice.org Document Templates


OpenOffice.org Macro Feature
A macro in OpenOffice is a saved sequence of steps or commands which can be called with the click of a button.

Macros are very useful in making repetitive tasks a lot more efficient. Say you need to put your signature, address and company logo at the end of a number documents you create using OpenOffice.

You can create a macro that does this for you. This way, all you have to do is to call the macro and it will fill in the necessary information.

Creating macros might seem rather intimidating at first, but it is quite simple to get started with it.


Record a macro
The simplest way to create a macro is to use OpenOffice’s built-in macro recording tool. You launch the macro recorder, run the steps you want to be recorded in the macro, then stop the recorder.

Voilà, your macro is now ready. Let’s look at how to do this. Go to Tools>Macros>Record Macro, then press the sequence of keystrokes you want.

At the end of your sequence, click on Stop Recording. In the new window that pops up, give the file a name and save it.

Try to come up with apt names for your macros, as weak names will drive you nuts in the future.


Run your saved macro
Once you have saved a macro in OpenOffice, it’s quite simple to run it. Go to Tools>Macros>Run Macro. A window will pop up with a list of all the macros available, the ones from the OpenOffice.org team, as well as the ones created by you.

Select the macro you want to execute and hit Run. The macro will execute. Errors, if any, will be displayed in a pop-up notification window.


Extensions
If you create a macro that you want to share with other users of the OpenOffice suite, there are two ways for you to do that.

You can either share the code used by the macro, or you can package the macro into an ‘extension’ and then share it via email or put it up for download.

The second method is usually the better approach. Let’s look at how to package an OpenOffice macro into an extension.

An OpenOffice extension pretty much consists of the code of an OpenOffice macro and some XML files, all wrapped up into a zip file.

To create an extension, first follow the steps shown above and create an OpenOffice macro. Once you have the macro saved in OpenOffice, there are two ways you can proceed.

You can either write the necessary XML files manually using a text editor, or you can use the OpenOffice tool, BasicAddonBuilder (BAB), to generate the XML files for you. Let’s look at the second method.


Install the BasicAddonBuilder
Installing the BasicAddonBuilder is quite a straightforward process. – just start here. This is the page for the BasicAddonBuilder OpenOffice extension.

On this page, click on the ‘Get it!’ button to begin the installation of BasicAddonBuilder. Once the download is complete, OpenOffice’s extension system will take over the installation.

Just follow the steps that it asks you to and you should soon be in business.


Create an OpenOffice.org extension
Now execute the macro you want to convert into an extension. You should see a new floating button pop up on your screen.

This is the BasicAddonBuilder. Click on the button and it will launch a window outlining the process of converting your macro into a plug-in.

This is a wizard that will run you through the creation of the extension step by step. Here you have the option of adding menu items for the extension.

This is particularly useful if you have two or more macros in one extension.

Follow the steps in the wizard and hit Forward for each step. Once you are done, hit the Finish button. This will result in the creation of an .oxt file.

This is the extension, all ready to be shared. You can find extensive documentation on the BasicAddonBuilder here.


Customise menu and toolbar
Writer is a productivity-oriented word processor. It doesn’t come across as a very attractive piece of software, but it’s very effective.

There have been a few who have asked for themes for Writer. However, their wishes haven’t been fulfilled yet.

Writer does, however, allow you to change the items and their order in the menu and toolbar. Go to Tools>Customize.

In the window that pops up, you will find a couple of tabs quite useful: Menus and Toolbars. Rearrange the order of items and add or remove something. Once you are done, hit OK to save the changes.


Extract Writer files
The default format used by OpenOffice Writer is ‘.odt’. As OpenOffice is a standards-compliant program, it uses XML for all its document settings and info.

The ‘.odt’ that your document is saved as is nothing but a zip file containing XML and other files. So you can extract a ‘.odt’ file by running the command “# unzip filename.odt”.

This command will extract the ‘.odt’ file and you should see a few XML files and some folders at the location where you have extracted the file.

Check out the extracted files. If you are familiar with XML you should be able to modify them. This is quite useful if you want to automatically modify your Writer files using another application.

Because all the files use the same XML markup, you can easily extract and modify the files from other applications.


Portable keyboard shortcuts
You can view and change the keyboard shortcuts used by Writer by going to Tools>Customize>Keyboard.

Note that you need to click on the radio button titled ‘Writer’ at the top-right corner of your screen to view Writer-specific shortcuts.

Once you are done modifying the keyboard shortcuts to your taste, you can hit the OK button to continue working in Writer.

You can also choose to save your customisation of the keyboard shortcuts to a file by clicking on the Save option, instead.

This allows you to choose from several shortcut options. If you want to import the keyboard shortcut settings from a file, hit the Load option.

You can take the saved file to another computer if you want to create the same set of shortcuts there.


Install extensions and add features
There are several very useful OpenOffice Writer extensions out there. Some favourite ones are ‘Sun PDF Import Extension’, ‘Professional Template Pack II – English’ and the ‘Writer’s Tools’. ‘Sun PDF Import Extension’ is a very useful extension that lets you import a PDF document and edit it.

If you install the ‘Professional Template Pack II – English’ extension, you will get several new professionally designed templates for your documents. ‘Writer’s Tools’ is a collection of tools that try to make OpenOffice Writer a more complete office suite.

This is a must-have for power users. It offers great document back-up options, a timer, task management tools, etc.


Calc Optimisations
Install templates
OpenOffice has a wonderful collection of templates for Calc, its spreadsheet application. There are calendars, loan payment planning sheets, planners, etc.

These templates are smart spreadsheet documents that will help you with a lot of the tasks you would usually use a spreadsheet for.

You can download, install and modify these templates. Download templates here, select a Calc template you like and click on the ‘Use It’ button. Once the template file is done downloading, open it with OpenOffice.

Now you can work on it, edit it and save it as a modified template if you like.

Conditional formatting for cells

Conditional formatting allows you to format cells differently, based on conditions which you can define. It’s a great way to automatically make some important information stand out. Go to Format>Styles and Formatting.

Right-click in the white space inside the window that pops up, and click on New.

Now create a new style. Assign it a name, a font and a different background colour. Create another style after you are done creating the first one.

Hit OK to save it, and close the Styles and Formatting window. Select the cells where you want conditional formatting to apply.

Go to Format >Conditional Formatting. Here you can assign the conditions for the formatting and which style to use for each condition.

For example, in the screenshot (left) we have asked Calc to use a particular style if the value in the cell is less than 100, and another if it is greater.


Create a Calc macro
Let’s look at how to create a simple macro for Calc. This macro will place two numbers in cells and then multiply them and put the result in a third cell.

Go to Tools>Macros>Organize Macros>OpenOffice.org Basic. In the window that pops up, click on the Organizer button and then click on New to create a new macro.

Once you pick the name, hit OK. You will see the OpenOffice.org Basic IDE open. Enter the following code in it, replacing whatever was there.

Then Save it and Run the macro. You should see the number 37 and 59 appear in cells A2 and A3, and their multiplied total in the cell A4.
Sub Main
Dim oSheet
oSheet = thisComponent.Sheets(0)
oSheet.getCellRangeByName(“A1”).String = “Simple Math”
oSheet.getCellRangeByName(“A2”).Value = 37
oSheet.getCellRangeByName(“A3”).Value = 59
oSheet.getCellRangeByName(“A4”).Formula = “=A2*A3”
End Sub


Impress Optimisations
Create a photo album
The Photo Album extension for OpenOffice.org Impress is a very useful plug-in. It allows you to create a photo album presentation with a few clicks of the mouse, within a few seconds.

You can download it here. Click on the ‘Get It’ link on the page to begin the download. To install, open the download zip file with Tools>Extension Manager.

To launch the Photo Album extension, go to Tools>Add-ons>Create Photo Album. Now direct it to the pictures you want to use in your photo album.

A couple of clicks later, you should have a ready-to-use presentation on your hands. You can tweak the transitions and change other things if you like.


Import Microsoft Office templates
MS Office ships with the Powerpoint presentation tool. Due to its popularity, there are several free (as well as commercial) templates available for it.

If you have MS Powerpoint installed on a computer, you can export the templates from it so that they can be imported into Impress.

First, you need to convert the templates to the OpenOffice format. Go to File>Wizards>Document Converter. Follow the wizard as it runs you through the process of converting the templates.


Go to Tools>Options>OpenOffice.org>Paths and click on Edit. Click on Add and add the path of the converted templates you want to add to OpenOffice. Now when you click on File>New>Templates and Documents, you should see your new templates available for use.


OpenOffice.org IDE for creating and editing macros
OpenOffice.org allows you to create macros by either recording your actions or by writing Basic code.

You can create OpenOffice macros by recording your actions, as we saw earlier. You can also use the Basic IDE to write the macros by hand.

When you record a macro, you can also open up the macro in the IDE and edit it to add more features, or just tweak it.

A good way to get started with creating macros using the IDE is to either record a macro and edit it, or to edit the code of one of the macros that ships with OpenOffice.

Go to Tools>Macros >Organize Macros>OpenOffice.org Basic. In the window that pops up, select the macro you want to edit and click on the Edit button. The Basic IDE will pop up with the code of the chosen macro.

There are a number of resources online where you can find samples of macro code – for example, here. The IDE is pretty helpful in that it allows you to watch variables and set up and monitor break points as you develop and test your macro code.

3 comments:

  1. No never tried it. What about its license? I am not concerned about cost here.

    ReplyDelete
  2. As far as I know, it is completely free for private and commercial use. :)

    http://www.ssuitesoft.com/legal.htm

    ReplyDelete
  3. Photo Album para Impress

    Nueva versión en español, mejorada y con nuevo look

    New Spanish version, improved and new look

    http://blog.open-office.es/index.php/extensiones/2010/07/02/photoalbum-es-1-0-2

    ReplyDelete