[Solved] Writing Macros - Where Do I Start?

Creating a macro - Writing a Script - Using the API

[Solved] Writing Macros - Where Do I Start?

Postby dave2007 » Wed Apr 16, 2008 11:41 pm

This question could be for Writer, Base, etc. as well, but I happened to come across a need to solve a problem with a macro in Calc.

The problem is that I have no idea where to start... I know that it is possible to record keystrokes but I am actually interested in writing a macro from scratch.

What do I need to learn to do that? Are macros written in Basic? Java? Is there a tutorial somwhere that teaches how to write OOo macros?

Thanks,
Dave
Last edited by dave2007 on Tue Apr 22, 2008 10:25 pm, edited 1 time in total.
dave2007
 
Posts: 10
Joined: Wed Apr 16, 2008 5:08 pm

Re: Writing Macros - Where Do I Start?

Postby Villeroy » Thu Apr 17, 2008 12:10 am

Go to this site's macro- forum with sticky thread on top, or http://www.oooforum.org/forum/viewforum.phtml?f=9 having a sticky link collection on top.
The office API is extremely large with a very steep learning curve. The built-in Basic dialect is best integrated but faulty, slow and clumsy.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 16.04, OpenOffice 4.x & LibreOffice 5.x
User avatar
Villeroy
Volunteer
 
Posts: 25142
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Writing Macros - Where Do I Start?

Postby dave2007 » Thu Apr 17, 2008 1:27 am

Villeroy wrote:Go to this site's macro- forum with sticky thread on top, or http://www.oooforum.org/forum/viewforum.phtml?f=9 having a sticky link collection on top.
The office API is extremely large with a very steep learning curve. The built-in Basic dialect is best integrated but faulty, slow and clumsy.


Thank you! Thanks to your link I arrived to the following tutorial:

http://www.kalitech.fr/clients/doc/VB_APIOOo_en.html

I am not sure that I understood the distinction between "the office API" and "the built-in Basic dialect". Until now I used to think that OpenOffice macro uses VisualBasic for its macro language in order to retain compatibility with Microsoft Office. Is still correct?

If so, what is "the office API"? What language should I be using in order to access the Office API?

Thanks,
Dave
dave2007
 
Posts: 10
Joined: Wed Apr 16, 2008 5:08 pm

Re: Writing Macros - Where Do I Start?

Postby Villeroy » Thu Apr 17, 2008 1:56 am

The Application Programming Interface is the collection of bells and whistles you can hit and blow utilizing a programming language. The Basic language is documented in the online help, the thing you talk to (API) is documented here: http://api.openoffice.org/
It can be seen as a hierarchy: http://api.openoffice.org/docs/common/r ... le-ix.html
The developer's guide describes how to use it and how to talk to the API by means of mature programming languages.
"The Book" for Basic macros by Andrew Pitonyak: http://www.pitonyak.org/book/ There is a document comprising the most important things.

I tend to discourage non-programmers starting with macro programming. It's like learning how to fly an airplane (huge and complex office suite) without having experience with any motor-driven vehicles (programming practice).
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 16.04, OpenOffice 4.x & LibreOffice 5.x
User avatar
Villeroy
Volunteer
 
Posts: 25142
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Writing Macros - Where Do I Start?

Postby kingfisher » Thu Apr 17, 2008 6:01 am

I'm not sure the tutorial you have linked is what you want. Visual Basic is not recognised by OpenOffice generally. The Novell versions can make some use of Visual Basic but that's it. Look at the links on the API site, especially the external links page

It would help you to have Andrew Pitonyak's free document (mentioned on that page), the Xray tool and the SDK. The SDK is an installable version of the material on the API site and is available from the mirrors at the head of the list in the stable/2.4.0 folder. The reason for installing it is that you can use it with the Xray tool.
Apache OpenOffice 4.1.2 (64 bit) on PCLinuxOS
User avatar
kingfisher
Volunteer
 
Posts: 2109
Joined: Tue Nov 20, 2007 10:53 am

Re: Writing Macros - Where Do I Start?

Postby Villeroy » Thu Apr 17, 2008 12:56 pm

Hi kingfisher,
VB is a generic programming language (Microsoft only). It can be used to call many APIs such as MSOffice, OpenOffice.org, the Windows API. What you mean is Visual Basic for Applications (VBA) or better refered as "Visual Basic for nothing but Microsoft Applications".
Unfortunately (IMHO), some people try to make OOo "translate" VBA code to something which makes sence with this different application. This approach may be of some academic interest but the practical use is close to zero, if not negative.

Dave's link however Programming OpenOffice.org with Visual Basic provides a tutorial on how to talk to OOo using the VB programming language or even VBA (yes, controlling a running OOo by a running MSOffice's VBA).
The StarBasic language built into OOo is a VBA's drunken cousin, running "within the office". No StarBasic without OOo, no VBA without MSO.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 16.04, OpenOffice 4.x & LibreOffice 5.x
User avatar
Villeroy
Volunteer
 
Posts: 25142
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 11 guests