Peschtra.com Logo
OOo Macros
 Use OpenOffice.org

A question was posed about calling a macro from inside another macro. This was an e-mail posted by Andrew Pitonyak, the Macro Maestro of OOo. It begins with an overview and then a line by line response.

Let me start with some text that I just recently created: If you want to learn programming in StarBasic, I am aware of a few documents that might be of use. Here is a list of resources that I recommend:

That said, I have provided inline answers to your questions:

> -----Original Message-----
> From: John Pettigrew [mailto:john@pettigrew.org.uk]
> Sent: Thursday, August 12, 2004 2:32 PM
> To: users@openoffice.org
> Subject: [users] Macro query
>
>
> I am in the process of switching from MS Office to OOo, and
> this means I have to translate my many macros. There are
> two things (so far) that are causing me a problem.
>
> 1) Is it possible to call a macro from within another macro?
> If I try this in a recording, OOo ignores any call to a macro
> (or, rather, it *performs* the macro but doesn't record that
> it's done so in the new macro). This makes it hard to work
> out for myself what the necessary command might be.

Yes, you may call a macro from within another macro. The problem is that the macro recorder does not record these sorts of things. To call another macro, you need to...
- Make certain that the library that contains the macro that you want to call is loaded
- You can not easily call a macro stored in another document, but you can call a macro stored in the same document or in the application itself.
- You simply call it, nothing special about it.

> 2) Is it possible to establish the character positions of the
> start and end of a piece of selected text from within a macro,
> and to place the cursor at specific positions?

I see this as more than one question. I can easily obtain a particular character location, but this location is not an index value or something that is easily readable. When you obtain selected text can be many things... Realize that you can have multiple disjoint selections. If I make a selection of one range of text, then I can easily find the start and end positions and place the cursor at specific locations. This is discussed starting at 7.1 in my macro document.

> TiA
>
> John
> --
> John Pettigrew XL Cambridge - contract and freelance editing
> Biology specialist Molecular biology, genetics, biotechnology
> john@xl-cambridge.com http://www.xl-cambridge.com/
> PGP public key available

--
Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.sxw
My Macro Book: http://www.hentzenwerke.com/catalog/oome.htm
Free Info: http://www.pitonyak.org/oo.php < /P >

Back to top. Ways to contribute. Contact the webmaster.

Google
 
Web www.openoffice.peschtra.com

Valid HTML 4.01!    Valid CSS!

Last edited 21 May 2005