asfenbo.blogg.se

Openoffice basic macros
Openoffice basic macros









openoffice basic macros
  1. OPENOFFICE BASIC MACROS HOW TO
  2. OPENOFFICE BASIC MACROS MANUAL
  3. OPENOFFICE BASIC MACROS CODE

To apply filters for all columns in all sheets: Dim cRange As new .CellRangeAddress StarDesktop.loadComponentFromURL(“private:factory/scalc”,”_blank”,0,args()) To create a new document: Dim args(3) as new .PropertyValue SNew=oBook.createInstance(“.Spreadsheet”) To insert a new sheet: Set oBook=ThisComponent To repeat this process for ‘N’ number of sheets: For i = 0 to N-1 XFound=iSheet.findNext(xFound,xSearchDescr ) ISheet.getCellByPosition(c,r).CellBackColor = RGB(255,0,0) XSearchDescr = iSheet.createSearchDescriptor()

openoffice basic macros

To search for a key pattern and highlight all cells in red: Sub FindAndRed(iSheet as Object) To count the number of consecutive non-empty cells in the first column: n=oSheet.Columns(0).computeFunction(.GeneralFunction.COUNT) To fill range A1:A10 with a sequence, use the following line of code: For i = 1 to 10 To insert five rows before the third row in the first sheet, use the following code: oSheet = ThisComponent.Sheets(0)

OPENOFFICE BASIC MACROS CODE

Let’s consider some more code snippets to learn how spreadsheets can be controlled in different ways by macros.

  • Line 10 changes the value of the A1 oCell to 10.
  • Line 9 accesses the A1 cell in the first sheet and stores it in oCell.
  • Line 8 accesses the same sheet and stores it in curSheet.
  • In Line 6 oBook.Sheets represents collection of all sheets in the present workbook and then displays the count.
  • Line 5 accesses the current document reference through ThisComponent and stores it to oBook.
  • Lines 2-4 declare the objects oBook, curSheet, oCell.
  • The following is the second example of a macro to access sheets, cells, etc, in a Calc document: 1 Sub MainĦ MsgBox “No.of sheets = “ & Ĩ curSheet = (“hello”)ĩ oCell = curSheet.getCellByPosition(0,0) Macros can be created and maintained from this IDE also (Figure 2). Other options are compile, stop, step into, step over, step out, toggle breakpoint, watch, etc.

    openoffice basic macros

    A simple one is Run Macro (shortcut: F5). We can use different items in the standard toolbar of the Basic IDE to run/debug macros. In the upcoming examples, we will concentrate more on Calc documents because there is greater business value for spreadsheet automation. This example works for all types of OOo documents. To make it available for all documents place it under ‘My Macros’. This macro is available to the present document only. When this code is run, a dialogue appears with the message, “Hello World”. 1 Sub Mainįigure 2 shows the editor, where you can enter the above code. The following is the code for a simple macro to greet people. Document Specific: These are also user written but on a ‘per document’ basis and are available to the current document only.Macros: A library of macros provided by OOo.My Macros: User written macros common for all documents.Macros are classified based on the location they are stored in. This opens a basic IDE to write code (Figure 1). Or, expand the standard, select an existing module and an available macro, and click on Edit to modify code. In the pane on the left, expand the current document’s name, select the standard, and click on New to create a new module. Start any OOo component (e.g., Calc), and access Tools→Macros→Organize Macros → Basics. OOo provides a macro organiser to create and maintain, and an IDE to code, run and debug macros. OOo comes with built-in tools for the development of macros in OOBasic, i.e., no external SDK or development tools are required. In this article we consider one simple language-OOBasic ( Basic) to develop our macros. In OOo, macros can be coded in many languages.

    OPENOFFICE BASIC MACROS MANUAL

    Overview of macrosĪ macro is like a script that can avoid a series of manual operations involved in GUI applications. OOo documents are based on the Open Document Format (ODF) from version 2.0 onwards. Note:, here onwards called OOo, comes with many components like Writer for text documents, Calc for spreadsheets, Impress for presentations, Draw for diagrams, Math for formulae and Base for database purposes. However, by preparing a macro, just a click or key combination will complete your work in a fraction of the time taken earlier. This will take a substantial amount of time every day. Imagine a situation where you have to create a new spreadsheet daily, and copy certain data and processes from the previous day’s sheet. So just with a click or short-cut key, John has managed to avoid a lot of manual and mundane repetitive tasks. He has prepared macros for frequent tasks, and whenever there is a need for a lot of GUI operations, he makes it simple by automating them with macros.

    OPENOFFICE BASIC MACROS HOW TO

    Well, John has recently learnt how to program his suite. So Sam is eager to know the secret of John’s success. Moreover, John’s work is more accurate and organised than Sam’s. Of late, John manages to finish his work early, whereas Sam has to stay in late to finish his. They handle a lot of documents every day and use for the purpose.











    Openoffice basic macros