[Solved] Macro to document macros

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
User avatar
frozbie
Posts: 15
Joined: Thu Sep 18, 2008 10:25 am

[Solved] Macro to document macros

Post by frozbie »

Hi,

I have a 5000 line basic module in StarOffice 8 Calc (PU10) which I have been tasked with modifying. The module contains some 30 macros, many of which have been recorded.

Does anyone know if it is possible to write a macro to scan through a module, find key words like Sub or Function and extract text to a Calc or Writer document?

I've had a quick search on the forum for documenting macros, and a hunt through the developers guide and basic documents but either have missed this or am not using the correct language to search for.

In versions of Microsoft Office I have written code to extract text from an Excel VBA module, but obviously the object model is very different to StarOffice VB.

It will not take me long to manually document the macros but if there is an easier way of doing it, it'd be good to know.

Thanks for any pointers.

Mark
Last edited by frozbie on Fri Sep 19, 2008 1:37 pm, edited 1 time in total.
User avatar
probe1
Volunteer
Posts: 277
Joined: Mon Oct 08, 2007 1:34 am
Location: Chonburi Thailand

Re: Macro to document macros

Post by probe1 »

maybe this extension could help:
OOo BasicTextListe2
BTL2 wrote:Macro to list the text of all Basic modules of all installed libraries to a writer document.


This version creates a 1000 page writer document in approx. 6 seconds, including a table of content, header and footer.

Document formatted depending on OOo's GUI language used: paper format "Letter" (if English is detected), otherwise German A4 format is used. ToC, page headers and footers presentation according to language.
Download, install (by double-clicking or from Tools>Extension Manager...>Add) then execute BasicTextListe2 within module BTL2 in library BTL2

Problem solved? Edit your first post and add "[Solved]" to the subject. Thanks.
Cheers
Winfried

DateTime2 extension: insert date, time or timestamp, formatted to your needs
User avatar
frozbie
Posts: 15
Joined: Thu Sep 18, 2008 10:25 am

Re: Macro to document macros

Post by frozbie »

Probe1,

That is a really useful extension (and not knowing about extensions before, I'll add the extensions library to my list of places to search in future.)

This seems to do the same job and suggests similar functionality to Microsofts VBA. I'll need to play around with the macro but this is what I needed. Thank you!

Regards

Mark
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: [Solved] Macro to document macros

Post by Villeroy »

For the readers who think if there could be more than Basic.
Change to my macro directory (Linux)

Code: Select all

$ cd ~/.openoffice.org2/user/Scripts/python]
$ python
> help()
Welcome to Python 2.5!  This is the online help utility.
[...]
help> BasicDialogs
BasicDialogs.py is the name of a module.

Code: Select all

Help on module BasicDialogs:

NAME
    BasicDialogs

FILE
    /home/andreas/.openoffice.org2/user/Scripts/python/BasicDialogs.py

CLASSES
    Office
    
    class Office
     |  Frequently used methods in office context
     |  
     |  Methods defined here:
     |  
     |  __init__(self, ctx=pyuno object (com.sun.star.uno.XComponentContext...sun.star.uno.XWeak,com.sun.star.lang.XComponent}})
     |  
     |  createUnoService(self, service)
     |  
     |  getCurrentComponent(self)
     |  
     |  getCurrentController(self)
     |  
     |  getCurrentFrame(self)
     |  
     |  getDesktop(self)

FUNCTIONS
    getBasicDialogResult(sLibName, sDlgName)
    
    show_Basic_Standard_Dialog1(*arg)

DATA
:
Another one:

Code: Select all

help> CalcMacros

Help on module CalcMacros:

NAME
    CalcMacros

FILE
    /home/andreas/.openoffice.org2/user/Scripts/python/CalcMacros.py

FUNCTIONS
    NowToActiveCell()
        Let a formula put the current time into the active cell,
        independent from language or null-date before converting to value.
        No formatting intended. Apply any date/time formatting you like.
    
    copyDownIntoSelections()
    
    copyUpIntoSelections()
    
    copyVisibles_Down(*args)
    
    copyVisibles_ToLeft(*args)
    
    copyVisibles_ToRight(*args)
    
    copyVisibles_Up(*args)
    
    dispatch_InputMode(oCtrl)
    
    getActiveCell(oView)
        Desparately missing in API. We extract from view data.
    
    getActiveSheetsRangesSelection(oDoc)
    
    getCurrentArray(oCell)
    
:
OK, it seems I have not written so much documentation into my modules. But I get all classes, methods with arguments, constants and so called doc-strings which can be attached to Python objects.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Post Reply