Using Macros

From NeoWiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 17:26, 8 July 2007 (edit)
Sardisson (Talk | contribs)
(Creating a Button for a Macro - add a few more style guide items)
← Previous diff
Current revision (12:08, 29 July 2009) (edit) (undo)
Lorinda (Talk | contribs)
(Forums and Wikis - add reference to OpenOffice.org BASIC Programming Guide in the OOo wiki)
 
(18 intermediate revisions not shown.)
Line 1: Line 1:
 +{{Fixme}}
==Recording a Simple Macro== ==Recording a Simple Macro==
Line 12: Line 13:
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: 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 {{menu|Tools}} choose {{menu|Macros}}, then {{menu|Organise Macros}}, and finally {{menu|NeoOffice Basic...}} +#Under the {{menu|Tools}} choose {{menu|Macros}}, then {{menu|Organise Macros}}, and finally {{menu|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.+#: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.
-*Choose the Library and Module where you want the Macro to be stored in the left panel+#If necessary, click on the disclosure triangle next to {{prefName|My Macros}} to show the items stored there.
-**e.g. in My Macros-Standard-Module1 (it highights this by default)+#*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.
-*Make sure that "Main" is highlighted in the right panel+#*It is not possible to add macros the NeoOffice Macros
-*click on {{menu|Edit}}.+#Click on the discolosure triangle next to the Library where you want to store the macro.
-*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. +#:Note: while the {{prefName|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 {{menu|Save}}+##Click on the {{Button|Organizer}} button
 +##In the {{Window|NeoOffice Basic Macro Organizer}} window, click on the {{Section|Libraries}} tab
 +##:''Note:'' If you are using another language (e.g. Python), the window will have a slightly different name.
 +##Make sure the {{Section|Location}} dropdown is set to {{prefName|My Macros & Dialogs}}
 +##:If you are storing the Macro in the document, however, choose the document name in the {{Section|Location}} dropdown.
 +##Click on the {{Button|New...}}
 +##Give the new Library a name
 +##Click {{Button|OK}}
 +##Click {{Button|Close}}
 +#Back in the {{Window|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 {{Button|Organizer}} button
 +##In the {{Window|NeoOffice Basic Macro Organizer}} window, click on the {{Section|Modules}} tab
 +##:''Note:'' If you are using another language (e.g. Python), the window will have a slightly different name.
 +##Click on the {{Button|New...}}
 +##Give the new Module a name
 +##Click {{Button|OK}}
 +##Click {{Button|Close}}
 +#Once your desired Library and Module are selected, make sure that "Main" is highlighted in the right panel
 +#click on {{menu|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 {{menu|Save}}
==Assigning a Shortcut Key to a Macro== ==Assigning a Shortcut Key to a Macro==
Line 33: Line 55:
==Adding a Toolbar Button for a Macro== ==Adding a Toolbar Button for a Macro==
- +# Go to Tools>Customize...
 +# Click on the {{section|Toolbar}} tab
 +# Choose the Toolbar you want to add the button to from the {{prefName|Toolbar}} dropdown near the top of the {{Window|Customize}} window.
 +# Click on the {{Button|Add...}} button
 +# In the {{section|Category}} box (in the {{Window|Add Commands}} window, scroll down to "NeoOfficeMacros" and highlight it
 +# 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
 +# Highlight one of those macros and click the {{Button|Add}} button
 +# Once back in the {{Window|Customize}} window, you can add or change the icon assigned to the button by selecting the Macro in the {{prefName|Commands}} box, clicking on the {{Button|Modify}} button and choosing {{Menu|Change Icon}}. Select an icon from those offered (note the up/down arrows that let you move through the collection) or click on the {{Button|Import...}} button to import an icon. (Icons must be 26x26 pixels to import correctly.)
 +# Click {{Button|OK}}
==Creating a Button for a Macro== ==Creating a Button for a Macro==
Line 47: Line 77:
==Documentation/Support for Macros== ==Documentation/Support for Macros==
-Chapter 10 of the [http://www.geocities.com/aussie_149/NeoUGWebsite/index.html NeoOffice User Guide] (draft) discusses Basic and Macros.  
-The Getting Started with Macros Guide to OpenOffice.org can be downloaded with [http://oooauthors.org/en/authors/userguide2/gettingstarted/published_final/0117GS-GettingStartedWithMacros.odt this link] Just remember to use the command key where the OpenOffice guide says to use the control key.+===Print and E-books===
 +====Free====
 +Chapter 10 of the [http://userguide.neooffice.org/userguide/ NeoOffice User Guide] discusses Basic and Macros. (The entire guide can be downloaded in pdf form from [http://userguide.neooffice.org/NeoOffice_User_Guide.pdf this link].)
 + 
 +The "Getting Started with Macros" guide to OpenOffice.org can be downloaded with [http://oooauthors.org/en/authors/userguide2/gettingstarted/published_final/0117GS-GettingStartedWithMacros.odt this link]. Just remember to use the command key where the OpenOffice guide says to use the control key.
[http://www.pitonyak.org/oo.php Andrew Pitonyak] has both a free downloadable document on OpenOffice Macros and a book that you can purchase. [http://www.pitonyak.org/oo.php Andrew Pitonyak] has both a free downloadable document on OpenOffice Macros and a book that you can purchase.
-The [http://www.oooforum.org/forum/viewforum.phtml?f=9 OpenOffice.org Macros and API forum] is a good source of information on Macros.+[http://www.packtpub.com/openoffice-ooobasic-calc-automation/book 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====
 +[http://www.pitonyak.org/oo.php Andrew Pitonyak] has both a free downloadable document on OpenOffice Macros and a book that you can purchase.
 + 
 +===Forums and Wikis===
 +The [http://wiki.services.openoffice.org/wiki/Documentation/BASIC_Guide 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 [http://user.services.openoffice.org/en/forum/viewforum.php?f=20&sid=27996753c1e4903d38b4302a63d40e46 OpenOffice.org Community Forum] has a forum on Macros.
 + 
 +The older [http://www.oooforum.org/forum/viewforum.phtml?f=9 OpenOffice.org Macros and API forum] is a good source of information on Macros.
:See especially [http://www.oooforum.org/forum/viewtopic.phtml?t=50952 this thread] with an extensive list of internet and print resources on Macros. :See especially [http://www.oooforum.org/forum/viewtopic.phtml?t=50952 this thread] with an extensive list of internet and print resources on Macros.
==Sources of Macros== ==Sources of Macros==
-[http://www.ooomacros.org/ OOoMacros.org] has a library of macros available for download.<br>+===Macros in Trinity Forum posts===
-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].+From time to time, someone will provide a macro for a specific task in the trinity forums.
 +*[http://trinity.neooffice.org/modules.php?name=Forums&file=viewtopic&p=26151#26151 to remove carriage returns]
 +*[https://trinity.neooffice.org/modules.php?name=Forums&file=viewtopic&p=47831#47831 Setting selection to Title Case]<br>
 +===Other Sources of Macros===
 +*[http://www.ooomacros.org/ OOoMacros.org] has a library of macros available for download.<br>
 + 
 +*[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. 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.
 +:Text of page is in German and English. These macros have not been tested on NeoOffice.
-{{botlangbarEN|[[Fr:Comment Utiliser les Macros|Français]]}}+{{botlangbarEN|[[Fr:Comment Utiliser les Macros|Français]] [[It:Usare_le_Macro|Italiano]]}}
[[Category:Tips and Hints]][[Category:NeoOffice]] [[Category:Tips and Hints]][[Category:NeoOffice]]

Current revision

This article is not up to date, or it needs structural or stylistic changes to conform with the rest of this wiki.

Contents

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

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

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

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

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.

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.

  • 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.

Sources of Macros

Macros in Trinity Forum posts

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

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