[Solved] OO Macro tutorial?

Discuss the spreadsheet application
Post Reply
scott1x
Posts: 32
Joined: Thu Jun 05, 2008 4:19 am

[Solved] OO Macro tutorial?

Post by scott1x »

The first and only spread sheet I every really felt comfortable with was Quattro Pro, by Borland. That was a LONG time ago! i need to use the macro facility of OO Calc and can't find a lot of information to get me started. Could anyone point me to a reference that would clearly explain the basics. I'm using open office, not star office.

TIA
Last edited by scott1x on Thu Jun 05, 2008 9:16 pm, edited 1 time in total.
User avatar
kingfisher
Volunteer
Posts: 2123
Joined: Tue Nov 20, 2007 10:53 am

Re: OO Macro tutorial?

Post by kingfisher »

There is a list of sources, including tutorials, here.
Apache OpenOffice 4.1.9 on Linux
scott1x
Posts: 32
Joined: Thu Jun 05, 2008 4:19 am

Re: OO Macro tutorial?

Post by scott1x »

kingfisher wrote:There is a list of sources, including tutorials, here.
Very impressive and totally uninformative. I did a find on macro and found canned macros I don't understand and don't want. And I found books for sale. Again, no help. I could probably poke around there for hours and not find what I need. That's why I asked for A reference.

Is there no place on the web where a reasonably straight forward introduction to calc macro programming is offered. You know, HELLO WORLD. You introduce the concepts, offer simple examples to the nature of the interface, give some basic rules for the language and leave the reader with an understanding of how to continue and provide links to more advanced examples.

Where can I find that?
Apache Open Office 4.1.0 on Ms Windows 7
User avatar
Hagar Delest
Moderator
Posts: 32670
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: OO Macro tutorial?

Post by Hagar Delest »

A search in the forum gave me that one: [Solved] Writing Macros - Where Do I Start?

Thanks to add '[Solved]' at beginning of your first post title (edit button) if your issue has been fixed.
LibreOffice 7.6.2.1 on Xubuntu 23.10 and 7.6.4.1 portable on Windows 10
scott1x
Posts: 32
Joined: Thu Jun 05, 2008 4:19 am

Re: OO Macro tutorial?

Post by scott1x »

Hagar de l'Est wrote:A search in the forum gave me that one: [Solved] Writing Macros - Where Do I Start?
That was a lot better, thank you! Following some of the links I found:
How to start learning UNO BASIC programming:

1st, stay with the latest stable version OO 2.1.0. Then you are more sure that any bugs are your bugs and not OO's Smile
2nd, you should install the IDL Reference, included in the SDK http://download.openoffice.org/680/sdk.html This is only for the documentation of the routines, not for programming
3rd, you should install Xray ( http://www.ooomacros.org/dev.php#101416 ). Xray expects the path where you installed the SDK.
4th, you should download Andrew Pitonyak's macro document ( http://www.pitonyak.org/AndrewMacro.sxw ), and buy his book ( http://www.hentzenwerke.com/catalog/oome.htm )
5th, you should single step through one or two makros from Andrew Pitonyak's document and inspect the major variables with XRay
6th, you should browse through http://www.oooforum.org/forum/viewtopic.phtml?t=5057 and references therein (!) to get an idea of the Model <--> Controller <--> Frame thing
7th, you should read http://api.openoffice.org/docs/Develope ... eDev.xhtml chapter 6.1.1 to 6.1.6. Do not expect to fully understand this after first reading - this is not necessary when starting with UNO.
8th, you should browse through DannyB's Basic Library ( http://www.oooforum.org/forum/viewtopic.phtml?t=14900 )
This leads me to believe that I need to buy books, spend quite a bit of time and energy to get started, and if I had all that time, I'd not really want macros.

Too bad. I know several "dialects" of basic, none of them visual or M$ specific; so, those who assume that the user has a knowledge of visual basic are way off base.

Who remembers the time when you got a product and actually received documentation on how to use it?

I DOO!!!

Thank you for your reply and assistance.... Moving on with my life now.....
Apache Open Office 4.1.0 on Ms Windows 7
User avatar
Hagar Delest
Moderator
Posts: 32670
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: OO Macro tutorial?

Post by Hagar Delest »

scott1x wrote:This leads me to believe that I need to buy books
Definitively not. All the links point to free (as beer) material except one clearly mentioned. Have you even tried them???
scott1x wrote:spend quite a bit of time and energy to get started
That's quite normal process when you try to learn something new.
scott1x wrote:Who remembers the time when you got a product and actually received documentation on how to use it?
Documentation is the SDK, available either online or by download. Try also Andrew's free document.
LibreOffice 7.6.2.1 on Xubuntu 23.10 and 7.6.4.1 portable on Windows 10
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: OO Macro tutorial?

Post by Villeroy »

Too bad. I know several "dialects" of basic, none of them visual or M$ specific; so, those who assume that the user has a knowledge of visual basic are way off base.
99% of the Basic language is documented in the help (they forgot a few details). It is a rather simplified Basic dialect with few very built-in functions and without class-modules (remember VBA in Office '95?).
As you may know, it makes a huge difference if you talk to Win-API, Outlook, Access, Excel or anything else by using the same VB language. Same language, different addressee. OOo is very, very different from the Microsoft apps. Personally I prefer Python as macro language for OOo for it's simplicity and object-orientation. In any case you need to understand the concepts of models, views and frames, modules, services and interfaces before you find your way through the office API. Since this API is made for any programming language you may think of, it's by far more abstract than the respective Microsoft APIs.
There is a browser for the API called "Xray": http://ooomacros.org/dev.php#101416 It is written entirely in StarBasic, utilizing the self-documenting features of every office-object.
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
scott1x
Posts: 32
Joined: Thu Jun 05, 2008 4:19 am

Re: OO Macro tutorial?

Post by scott1x »

Hagar de l'Est wrote:
scott1x wrote:This leads me to believe that I need to buy books
Definitively not. All the links point to free (as beer) material except one clearly mentioned. Have you even tried them???
scott1x wrote:spend quite a bit of time and energy to get started
That's quite normal process when you try to learn something new.
scott1x wrote:Who remembers the time when you got a product and actually received documentation on how to use it?
Documentation is the SDK, available either online or by download. Try also Andrew's free document.
Almost every reference I've followed ended up with me needing to buy a book to understand what someone thinks I should already know. And I'm not really learning something new. I've written macros for several products from other vendors, although it was a few years ago. I used supplied documentation that was organized to be comprehensible and assumed no prior knowledge. I've run into the term SDK, but I have no desire to become a developer and distribute code, and that's what I had the impression that is.

Are you saying I need a developers package to write a simple macro? I can bring up tools/macros/organize dialog and see the basic interface and IDE, but have no idea how to even insert a value into a cell, reference the document or do basic navigation.

WHERE can I find that sort of information?
Apache Open Office 4.1.0 on Ms Windows 7
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: OO Macro tutorial?

Post by Villeroy »

WHERE can I find that sort of information?
If you know the difference between services and interfaces in UNO:
http://api.openoffice.org/docs/common/r ... le-ix.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
User avatar
Hagar Delest
Moderator
Posts: 32670
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: OO Macro tutorial?

Post by Hagar Delest »

scott1x wrote:Are you saying I need a developers package to write a simple macro?
No. I'm not a developer at all and I've written or modified macros, not always so simple.
I've learned macros writing them in fact. What you're looking for won't be available for free I think because it implies a hard work that is closer to a teaching course than a tutorial. So if you don't want to pay, study the different code snippets available and adapt them.

Documentation is one of the most difficult parts of a project. It requires a lot of energy and time. Better put energy improving the product itself than documenting it in the details IMHO, as soon as the minimum required is available for those who want to do some code.
LibreOffice 7.6.2.1 on Xubuntu 23.10 and 7.6.4.1 portable on Windows 10
scott1x
Posts: 32
Joined: Thu Jun 05, 2008 4:19 am

Re: OO Macro tutorial?

Post by scott1x »

Villeroy wrote: 99% of the Basic language is documented in the help (they forgot a few details). It is a rather simplified Basic dialect with few very built-in functions and without class-modules (remember VBA in Office '95?).
Actually, I don't. I never have used any visual basic. Never programmed for windows or used the windows API. Most of my experience was main frames.
Villeroy wrote: As you may know, it makes a huge difference if you talk to Win-API, Outlook, Access, Excel or anything else by using the same VB language. Same language, different addressee.
Again I don't. I've never used Outlook (what is that thing, anyway?) Access, Excell or any other M$ product. I've programmed in "C", BAL, ALC, Cobol, Clarion, RPG II, Pascal, PEARL, Basic, GWBasic, Qbasic, real basic, free basic and a wee bit of JAVA script. NOTHING with the word visual in it, nor M$ oriented.
Villeroy wrote: OOo is very, very different from the Microsoft apps. Personally I prefer Python as macro language for OOo for it's simplicity and object-orientation. In any case you need to understand the concepts of models, views and frames, modules, services and interfaces before you find your way through the office API. Since this API is made for any programming language you may think of, it's by far more abstract than the respective Microsoft APIs.
Sounds like a crap load of overkill to write a simple macro. I need to write a relatively simple macro to do a simple calculation, roll a couple of values and modify two or three cells. Simple, straight forward and I need to download SDK, Xray, and master OO APIs.

Interesting.
Villeroy wrote: There is a browser for the API called "Xray": http://ooomacros.org/dev.php#101416 It is written entirely in StarBasic, utilizing the self-documenting features of every office-object.
I followed the above link and the first thing it said was: IF SDK is installed. It isn't, so I guess that's not much help for me, huh? Like I said, if I have to install an entire environment, master APIs and figure out some obtuse notation convention, it's simply more trouble than it's worth.

Frankly, I've found comprehensible documentation for all of the open office products very lacking. The basic interface is rather friendly, so I can figure most of what I need, and with the help of other kind users, figure out some of the things that are not obvious. If I hadn't prior experience with Borland's Quattro Pro, I'd be totally lost in calc, like my daughter is. She has me write most of her spread sheet needs for her, then she simply modifies them for her needs.

I don't know what the solution is, other than good documentation, but apparently, that's not forth coming for awhile, yet. I've lived w/o macros this long and it looks like I'll have to continue in that vein. I do appreciate the replies, but all of them reference materials I have no knowledge of - like VBA and win apis. I simply do not want to learn all of that to write a macro that'll include about six calculations based on the value of the current cell and modify two or three other values based on a calculation for that value.

It should not be that hard!
Apache Open Office 4.1.0 on Ms Windows 7
scott1x
Posts: 32
Joined: Thu Jun 05, 2008 4:19 am

Re: OO Macro tutorial?

Post by scott1x »

Villeroy wrote: If you know the difference between services and interfaces in UNO:
http://api.openoffice.org/docs/common/r ... le-ix.html
I don't. I'd never heard of UNO until yesterday.
Apache Open Office 4.1.0 on Ms Windows 7
scott1x
Posts: 32
Joined: Thu Jun 05, 2008 4:19 am

Re: OO Macro tutorial?

Post by scott1x »

Hagar de l'Est wrote:
scott1x wrote:Are you saying I need a developers package to write a simple macro?
No. I'm not a developer at all and I've written or modified macros, not always so simple.
I've learned macros writing them in fact. What you're looking for won't be available for free I think because it implies a hard work that is closer to a teaching course than a tutorial. So if you don't want to pay, study the different code snippets available and adapt them.

Documentation is one of the most difficult parts of a project. It requires a lot of energy and time. Better put energy improving the product itself than documenting it in the details IMHO, as soon as the minimum required is available for those who want to do some code.
I agree with you, guy!!!!! Documentation is a BEAR! I have the displeasure to have had to write some of it and I hated it! And since Open Office is free, I can't really complain that fine documentation is not online for free!. If there was a good tutorial, I'd not hesitate to buy it, but I've spent good money on tutorials that weren't worth the paper they were printed on, so unless I can hold it in my hot little hands, I'm shy of putting out any real money.

I'd study code snippets if I could, but I not sure how to install a macro if I do get one. One I saw said down load and install it. HOW DO I INSTALL THE DAMN THING? See the problem?
Apache Open Office 4.1.0 on Ms Windows 7
User avatar
Hagar Delest
Moderator
Posts: 32670
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: OO Macro tutorial?

Post by Hagar Delest »

scott1x wrote:HOW DO I INSTALL THE DAMN THING? See the problem?
That's a different question: [Tutorial] How to install a code snippet.
LibreOffice 7.6.2.1 on Xubuntu 23.10 and 7.6.4.1 portable on Windows 10
scott1x
Posts: 32
Joined: Thu Jun 05, 2008 4:19 am

Re: OO Macro tutorial?

Post by scott1x »

Hagar de l'Est wrote:
scott1x wrote:HOW DO I INSTALL THE DAMN THING? See the problem?
That's a different question: [Tutorial] How to install a code snippet.
Now, that's a response I can use!

Is there a concise reference on how to reference cells and such available so that some of the notation I've seen will actually make senese?
Apache Open Office 4.1.0 on Ms Windows 7
User avatar
Hagar Delest
Moderator
Posts: 32670
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: OO Macro tutorial?

Post by Hagar Delest »

Don't know, I'm not familiar with Calc area. Try to ask in the forum about macros, giving the details of your need.

Thanks to add '[Solved]' at beginning of your first post title (edit button) if your issue about the tutorial has been fixed.
LibreOffice 7.6.2.1 on Xubuntu 23.10 and 7.6.4.1 portable on Windows 10
scott1x
Posts: 32
Joined: Thu Jun 05, 2008 4:19 am

Re: OO Macro tutorial?

Post by scott1x »

Hagar de l'Est wrote:Don't know, I'm not familiar with Calc area. Try to ask in the forum about macros, giving the details of your need.

Thanks to add '[Solved]' at beginning of your first post title (edit button) if your issue about the tutorial has been fixed.
I have made that post, and now, since I know how to install a macro, may find the answer enlightening!

Thank you.
Apache Open Office 4.1.0 on Ms Windows 7
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: OO Macro tutorial?

Post by Villeroy »

Some more background:
The system wide macro container Tools>Macros>Basic>Organize..."OpenOffice.org Macros" contains lots of exmples shipped with the office. Basic provides some introspective methods Dbg_Methods, Dbg_Properties, Dbg_SupportedInterfaces. The IDE shows a tree view for objects (this is far from perfect).
You store your own Basic code in user specific macro container "My Macros" or (if it is related to specific documents) you store it in the respective document's macro container.
So we have 2 general containers and one for each loaded document.
[OOo Macros]
[My Macros]
[mytext.odt]
[mysheet.ods]
[myfoils.odp]
[myvectors.odg]
Each container has an empty default library "Standard". You add your own libraries to containers, your modules to libraries and define subs and functions in the modules.
Basic knows a little helper variable "ThisComponent" which refers to the currently active document when used in the general containers. In document containers "ThisComponent" refers to the containing document.
Most Basic-macros use ThisComponent as the entry point into the API from where they derive everything else.
Every coder of Basic macros (even when coding in other languages) makes use of the above linked xray tool. There is an alternative tool written in Java, I never tried.
Having xray and a local copy of the SDK (just for the html-documentation) you can inspect every object in depth and load the respective html of the scanned object into your preferred browser.
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
scott1x
Posts: 32
Joined: Thu Jun 05, 2008 4:19 am

Re: OO Macro tutorial?

Post by scott1x »

That all makes perfect sense. Thank you. Since the macro I need is very simple, and only modifies one row, I'm hoping that I can avoid extensive debugging and won't need xray or SDK. I could get around to using them, in the future, but at the moment, I'd have trouble finding the time.

I do appreciate the help and references. Actually, I did manage to get a "hello world" macro to run, so progress is being made.

Thanks to those who responded.
Apache Open Office 4.1.0 on Ms Windows 7
Post Reply