Re: Macro question

Dick Hoffman <[email protected]> Tue, 12 Jan 2010 16:36:57 -0500
Newsgroups gmane.comp.openoffice.dba.user
Message-ID <[email protected]>
Frank Schoenheit, Sun Microsystems Germany wrote:
> Hi Dick,
>
>> I've used OOo Base to construct a database and wrote a macro in Basic to
>> connect to the database, issue an SQL query and write out a report of
>> statistics calculated from the results of the query. All work very well.
>> Now I'd like to write another macro that issues a different query and
>> processes the results. However, OOo wants to append the new macro to the
>> previous one. No matter what I try, it will not let me write the new
>> macro as a separate entity. What am I missing here?
>
> Not sure I understand what you mean with "append the new macro to the
> previous one" ...
>
> Macros in OOo are organized into libraries, with a library containing
> (one or) multiple modules, with a module containing (one or) multiple
> functions/subs.
>
> The Basic organizer (via "Tools/Macros/Organize Macros/StarOffice Basic
> .../Organizer") will allow you to manipulate this structure.
>
> If playing with the organizer doesn't help you, please elaborate the
> problem.
>
> Ciao
> Frank
>
OK, here are the steps I went through to create a second macro.
1. I double-clicked on my dbase to activate Base.
2. I then selected TOOLS -> MACROS -> ORGANIZE MACROS -> OpenOffice.org 
Basic. That opened a window with a box that displayed a list of items 
including my dbase.
3. Clicking on the "+" to the left of my dbase dropped down a folder 
named "STANDARD".
4. Clicking on the "+" to the left of STANDARD revealed it contained a 
Macro named "Stat1" which is the first macro I wrote. I want to create 
another macro in this folder called STANDARD.
5. I click on the folder called STANDARD to highlight it, type the new 
macro name "Species" in the box provided and select "NEW" on the right.
6. A window opens to enter the Basic code with the Basic statements
"Sub Species" and "End Sub" already provided. The statements for the 
macro "Stat1" are visible above the "Sub Species" statement so this new 
macro is being appended to the previous one.
7. I enter the rest of the code for "Species" and close the window. (For 
some reason, the provided "End Sub" is not recognized and I have to 
enter another one.) I again look at what macros are listed in STANDARD 
and only "Stat1" is listed. If I highlight "Stat1" the list of macros on 
the right now shows "Stat1" and "Species" as macros. If I highlight 
"Species" and select RUN only that macro executes, which is OK.
8. What I expected to get at #6 above was an empty widow or one with 
only the two statements in it in which to enter the new macro which 
would then show up as a macro in the folder STANDARD when I repeated #4 
above.
Obviously I'm not doing something right. The two macros are completely 
independent of each other, neither refers to the other, so it would be 
neater, if nothing else, to separate them. Hope this clarifies my problem.
Dick