|
Using Macros
From NeoWiki
Revision as of 13:25, 25 April 2008 (edit) Lorinda (Talk | contribs) (→Saving Code as a Macro - add instructions for creating new libraries and modules, other improvements.) ← Previous diff |
Revision as of 18:19, 20 June 2008 (edit) (undo) Lorinda (Talk | contribs) (→Sources of Macros - add link to article on Writer Tools) Next diff → |
||
Line 95: | Line 95: | ||
In the forums at trinity, yoxi provides the code for a macro [http://trinity.neooffice.org/modules.php?name=Forums&file=viewtopic&p=26151#26151 to remove carriage returns].<br> | In the forums at trinity, yoxi provides the code for a macro [http://trinity.neooffice.org/modules.php?name=Forums&file=viewtopic&p=26151#26151 to remove carriage returns].<br> | ||
[http://nothickmanuals.info/doku.php/writertools Writer Tools] A set of macros that appear as an additional menu in OpenOffice.org. | [http://nothickmanuals.info/doku.php/writertools 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 [http://trinity.neooffice.org/modules.php?name=Forums&file=viewtopic&p=35682#35682 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.''<br> | + | :''N.B. Currently Writer Tools do not appear to work in NeoOffice. See [http://trinity.neooffice.org/modules.php?name=Forums&file=viewtopic&p=35682#35682 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, [http://nothickmanuals.info/doku.php/articles:ooowt this article] provides some background on how to use them.''<br> |
[http://www.re-solutions.de/ooo/makros/ wr.Makros] Macros for various components of OpenOffice.org. | [http://www.re-solutions.de/ooo/makros/ 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. | :Text of page is in German and English. These macros have not been tested on NeoOffice. |
Revision as of 18:19, 20 June 2008
Contents |
Recording a Simple Macro
- Go to Tools, choose Macros and then Record Macro
- Perform the series of steps you want the macro to do for you automatically. (For example, apply a particular style)
- When you have finished all the steps, click on Stop recording
- In the window that appears, give the macro a name.
- Assign the macro to a Library and Module (See chapter 10 of the NeoOffice User Guide mentioned below for more information)
- Click Save when you have the settings the way you want
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:
- 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.
- 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
- 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:
- Click on the Organizer button
- 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.
- 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.
- Click on the New...
- Give the new Library a name
- Click OK
- Click Close
- 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:
- Make sure the Library you want to add the Module to is selected
- Click on the Organizer button
- 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.
- Click on the New...
- Give the new Module a name
- Click OK
- Click Close
- Once your desired Library and Module are selected, make sure that "Main" is highlighted in the right panel
- click on Edit.
- 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.
- Click Save
Assigning a Shortcut Key to a Macro
- Go to Tools>Customize...
- Click on the Keyboard tab
- In the Category box, scroll down to "NeoOfficeMacros" and highlight it
- 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
- Highlight one of those macros
- In the Shortcut Keys box select the key you want to assign to that macro
- Set the radio button to specify if the key assignment is for all of NeoOffice or only for Writer
- click Modify
Adding a Toolbar Button for a Macro
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:
- Go to the View menu, open the Toolbars sub-menu, and choose Form Controls.
- 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.
- Draw the button as you wish. Control-click it, choose Control... in the context menu.
- Click on the General tab and give your button a title (label).
- 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.
- Click on the Macro... button.
- Choose your macro. Click on OK and again on OK, and then close the Properties: Button window.
- Quit the Design mode by clicking on the little triangle in the top right of the toolbar.
Documentation/Support for Macros
Print and E-books
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).
For Purchase
Andrew Pitonyak has both a free downloadable document on OpenOffice Macros and a book that you can purchase.
Forums and Wikis
The Open Office.org wiki has a section on BASIC.
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.
Sources of Macros
OOoMacros.org has a library of macros available for download.
In the forums at trinity, yoxi provides the code for a macro to remove carriage returns.
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.