Beginner Macro Tutorial.....

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
scott1x
Posts: 32
Joined: Thu Jun 05, 2008 4:19 am

Beginner Macro Tutorial.....

Post by scott1x »

I am not a whiz or object oriented programmer, but I just went through the process of trying to get a macro up and running in open office calc and my experiences may help you. Check out the wiki for more detail:
http://en.wikipedia.org/wiki/Object-ori ... rogramming

That should confuse you! To help clarify matters, I've documented my first macro experience. Since it is up and running, my efforts may aid yours.... Rather than clutter up the forum, here's a link to what I found.

http://catfangz.com/OOMacro.html
Apache Open Office 4.1.0 on Ms Windows 7
TerryE
Volunteer
Posts: 1402
Joined: Sat Oct 06, 2007 10:13 pm
Location: UK

Re: Beginner Macro Tutorial.....

Post by TerryE »

Object Oriented Basic is a bit of an oxymoron isn't it :-)

The UNO API and the many services that are provided to support access to OOo documents are reasonably Object oriented, but the OOo Basic is certainly not. Just go through the article that you reference and ask yourself how many of these concepts are supported by Basic and the answer is almost none (try extending an UNO class for example).

What Basic does do is to provide a simple abstraction interface over UNO so you don't have to worry about Interfaces and that you can treat the interface methods and properties as belonging directly to the object. It also does some nice tricks such as mapping the getXXX and set XXX methods onto pseudo properties. It also bares a superficial resemblance to VBA. Apart from that the implementation (I've been through most of the code) is terrible[/b] and contains many architectural flaws.

Python is a far more sound basis (and supports proper object orientation by the way). The only thing that it really lacks as a macro language for executing in-process is a decent IDE. Having one would be a great enhancement to OOo.

But don't let me put you off. Keep up the good work and I look forward to your first Python post :-)
Ubuntu 11.04-x64 + LibreOffice 3 and MS free except the boss's Notebook which runs XP + OOo 3.3.
scott1x
Posts: 32
Joined: Thu Jun 05, 2008 4:19 am

Re: Beginner Macro Tutorial.....

Post by scott1x »

I have NO argument with anything you say!. The fact is, I'd never heard of python until I started looking at the macro facility of calc! As it happens, I know basic, and for quick and dirty, it gets projects up and running. It seem that the implementation of python macros required a lot more work than basic, and for the simple task I had, I didn't want to invest the time.

HOWEVER, having said that.... Could you recommend some basic reading on python? I am interested in learning.

Scott ;)

PS, Don't do VBA, either. I come from a mainframe environment.
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Beginner Macro Tutorial.....

Post by Villeroy »

HOWEVER, having said that.... Could you recommend some basic reading on python? I am interested in learning.
http://www.ibiblio.org/swaroopch/byteof ... files/120/
Having some programming exprerience and a decent code editor, a free weekend should suffice. The interpreter (v2.3) comes with a standard installation of OpenOffice.org as <OOo_install>/program/python[.exe]

As always, things become complicated when OOo comes into play: http://udk.openoffice.org/python/python-bridge.html
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