Loading
Warning: This web page is maintained by a small number of volunteers, so this page may contain old or incorrect information. If the information on this web page does not work or does not make sense, please visit the main NeoOffice website or the NeoOffice online support forums for the most current information.

Using Macros

From NeoWiki

Jump to: navigation, search
This article is not up to date, or it needs structural or stylistic changes to conform with the rest of this wiki. You can help the NeoOffice community by fixing it. If you do not have a NeoWiki account, please follow the steps on the New User page to request one.

Contents

[edit] Recording a Simple Macro

  1. Go to Tools, choose Macros and then Record Macro
  2. Perform the series of steps you want the macro to do for you automatically. (For example, apply a particular style)
  3. When you have finished all the steps, click on Stop recording
  4. In the window that appears, give the macro a name.
  5. Assign the macro to a Library and Module (See chapter 10 of the NeoOffice User Guide mentioned below for more information)
  6. Click Save when you have the settings the way you want

[edit] Saving Code as a Macro

Sometimes you may find code provided in a forum or in a text document that you want to add as a macro. To do so, follow these steps:

  1. Under the Tools choose Macros, then Organise Macros, and finally NeoOffice Basic...
    Note that if the code is written in something other than NeoOffice/OpenOffice.org Basic, you need to choose the corresponding language at this point.
  2. If necessary, click on the disclosure triangle next to My Macros to show the items stored there.
    • If the Macro is only to be used in the current document, and/or if you plan to send the document to another user, you should click on the disclosure triangle next to the icon for the document in which you want to store the macro.
    • It is not possible to add macros the NeoOffice Macros
  3. Click on the discolosure triangle next to the Library where you want to store the macro.
    Note: while the Standard Library is selected by default, it storing Macros in the Standard library runs the risk of having those Macros deleted in certain circumstancs. Thus it is recommended to store all your macros in libraries you create and name. To create a new Library:
    1. Click on the Organizer button
    2. In the NeoOffice Basic Macro Organizer window, click on the Libraries tab
      Note: If you are using another language (e.g. Python), the window will have a slightly different name.
    3. Make sure the Location dropdown is set to My Macros & Dialogs
      If you are storing the Macro in the document, however, choose the document name in the Location dropdown.
    4. Click on the New...
    5. Give the new Library a name
    6. Click OK
    7. Click Close
  4. Back in the NeoOffice Basic Macros, click on the the Module you want to add the Macro code to. Modules are represented by scroll-like icons. If you wish to create a new Module, do the following:
    1. Make sure the Library you want to add the Module to is selected
    2. Click on the Organizer button
    3. In the NeoOffice Basic Macro Organizer window, click on the Modules tab
      Note: If you are using another language (e.g. Python), the window will have a slightly different name.
    4. Click on the New...
    5. Give the new Module a name
    6. Click OK
    7. Click Close
  5. Once your desired Library and Module are selected, make sure that "Main" is highlighted in the right panel
  6. click on Edit.
  7. Paste the code in anywhere below the Main/End Sub lines - making sure you don't paste in the middle of any other macros you saved; a couple of lines after Main's End Sub line is an obvious choice.
  8. Click Save

[edit] Assigning a Shortcut Key to a Macro

  1. Go to Tools>Customize...
  2. Click on the Keyboard tab
  3. In the Category box, scroll down to "NeoOfficeMacros" and highlight it
  4. Burrow your way down through "user" and the library and module your macros are stored in. Eventually your new macros will be listed in the Function box
  5. Highlight one of those macros
  6. In the Shortcut Keys box select the key you want to assign to that macro
  7. Set the radio button to specify if the key assignment is for all of NeoOffice or only for Writer
  8. click Modify

[edit] Adding a Toolbar Button for a Macro

  1. Go to Tools>Customize...
  2. Click on the Toolbar tab
  3. Choose the Toolbar you want to add the button to from the Toolbar dropdown near the top of the Customize window.
  4. Click on the Add... button
  5. In the Category box (in the Add Commands window, scroll down to "NeoOfficeMacros" and highlight it
  6. Burrow your way down through "My Macros" and the library and module your macros are stored in. Eventually your new macros will be listed in the Function box
  7. Highlight one of those macros and click the Add button
  8. Once back in the Customize window, you can add or change the icon assigned to the button by selecting the Macro in the Commands box, clicking on the Modify button and choosing Change Icon. Select an icon from those offered (note the up/down arrows that let you move through the collection) or click on the Import... button to import an icon. (Icons must be 26x26 pixels to import correctly.)
  9. Click OK

[edit] Creating a Button for a Macro

You can create a button which runs a macro in a Writer or a Calc document by using the followiing method:

  1. Go to the View menu, open the Toolbars sub-menu, and choose Form Controls.
  2. Click on the little triangle on the right top of the toolbar that appears to activate the design mode. Click on the Push button icon. The pointer changes into a cross.
  3. Draw the button as you wish. Control-click it, choose Control... in the context menu.
  4. Click on the General tab and give your button a title (label).
  5. Click on the Events tab. Click on the event, for example Mouse button pressed and click on the ... button to open the Assign action window.
  6. Click on the Macro... button.
  7. Choose your macro. Click on OK and again on OK, and then close the Properties: Button window.
  8. Quit the Design mode by clicking on the little triangle in the top right of the toolbar.

[edit] Documentation/Support for Macros

[edit] Print and E-books

[edit] Free

Chapter 10 of the NeoOffice User Guide discusses Basic and Macros. (The entire guide can be downloaded in pdf form from this link.)

The "Getting Started with Macros" guide to OpenOffice.org can be downloaded with this link. Just remember to use the command key where the OpenOffice guide says to use the control key.

Andrew Pitonyak has both a free downloadable document on OpenOffice Macros and a book that you can purchase.

Learn OpenOffice.org Spreadsheet Macro Programming: OOoBasic and Calc automation by Dr. Mark Alexander Bain (print or e-book for purchase). Look for the link to download a sample chapter (On working with Databases).

[edit] For Purchase

Andrew Pitonyak has both a free downloadable document on OpenOffice Macros and a book that you can purchase.

[edit] Forums and Wikis

The Open Office.org wiki has a section on BASIC.

  • This is essentially a wiki-fied version of the "OpenOffice.org BASIC Programming Guide," which can be also be downloaded in pdf or odt format from the links on that page.

The OpenOffice.org Community Forum has a forum on Macros.

The older OpenOffice.org Macros and API forum is a good source of information on Macros.

See especially this thread with an extensive list of internet and print resources on Macros.

[edit] Sources of Macros

[edit] Macros in Trinity Forum posts

From time to time, someone will provide a macro for a specific task in the trinity forums.

[edit] Other Sources of Macros

  • Writer Tools A set of macros that appear as an additional menu in OpenOffice.org.
N.B. Currently Writer Tools do not appear to work in NeoOffice. See this thread in trinity. Should anyone be able to adapt them to work in NeoOffice, please post the solution(s) in the aforementioned trinity thread. If a solution is found, this article provides some background on how to use them.
  • wr.Makros Macros for various components of OpenOffice.org.
Text of page is in German and English. These macros have not been tested on NeoOffice.


This article in other languages: Fran├žais Italiano
Personal tools