![]() ![]() Cells can be referenced using the co-ordinate system where (0,0) refers to cell at row-0 and column-0. The important thing here is the expression, sheet.getCellByPosition(0, 0).String which gets the contents of first cell in the first row. ThisComponent is the LibreOffice object that references the current spreadsheet (or a written document in case of Writer). MsgBox(sheet.getCellByPosition(0, 0).String)ĭim is a keyword used to declare a variable but declaration is totally optional unless Option Explicit is specified at the beginning of the module. The following piece of code does exactly this: One of the most basic things needed for automation is reading a cell’s contents. This will open the LibreOffice Macro Editor as a separate window. ![]() After that, if you want to create a macro specific to your spreadsheet (as usually is the case), expand your spreadsheet file on left and select Standard and click New. To create a macro, just open the spreadsheet in LibreOffice and go to Tools->Macros->Organize Macros->LibreOffice Basic menu. Whilst macros can be created in Writer and Draw too, in this specific tutorial, we will restrict ourselves to spreadsheets (Calc). Recipe 0: How to create a LibreOffice macro Recipe 0: How to create a LibreOffice macro.In this tutorial, we will see ten such useful macros that can help you with various automation tasks. A LibreOffice Basic macro is just a function or sub procedure which does a specific useful task. This makes Basic equally useful for both power users and programmers. For instance, upper/lower case doesn’t matter for variable names or keywords ( if/IF, sub/Sub, function/Function are equivalents), function braces are optional like Ruby and type-conversion happens automatically. The best thing about macros is that they are written in a very easy language called Basic.Īs it’s very name suggests, Basic is a lenient programming language actually designed with ease of use in mind. Macros are a great way to automate tasks in Spreadsheet applications, be it the good old Microsoft Excel or the equally efficient FOSS alternative, LibreOffice Calc. ![]()
0 Comments
Leave a Reply. |