How to use macros in LO to capture Object Model and Code

I am learning the object model and coding in LO, after long experience in MS Office’s VBA.

I notice that in LO, i can not use the Macro creation to reliably, or simply, learn the statements/codes/variables. And that macro creation often creates code that doesn’t work.

For example: I turned on Macro Recording in Calc, then: created a shape, changed its size and color, changes the border size and color, and then ended recording.

The macro could not be executed to duplicate my effort, and did not complete the coding (leaving REM statements…)

In Office/VBA, a recorded macro plainly set out what happened, and I could duplicate it inside my code.

What am I missing ?

I have seen / played with the MRI extension (which is…convoluted and a little awkward to use), started in on Andrew Pitonyak’s AndrewMacro.ODX and gone thru his Version 4 of his book (freely available at pitonyak.org), but I would welcome an easier way to capture a precise maneuver in LO

Suggestions/Ideas solicited…

Hello,

Sorry but don’t think so. MRI (or XRay) is essential to object inspection.
Documentation is all over the place. See the links in the following posts:

@Ratslinger … Hmmm… thanks. I guess I wonder … where can I go to suggest that the wonderful volunteers put some effort into getting the macro recording to accurately record code that executes ? Or am I missing something there about how it records and works …?

All requests for enhancements can be made at Bugzilla.
.
You may want to search for macro recording or such first to se open requests…
.
Don’t believe you will get far with this. The API is extremely large and would be a nightmare to barely cover a portion.
.
Best to get at the documents available like OOME by Pitonyak and the Developer guides noted in the links.

Please never suggest that wonderful volunteers put some effort anywhere you like them to. This is … simply wrong: there’s no shortage of tasks the volunteers are doing, as they like, and anyone thinking that the volunteers are waiting for someone’s guidance is misguided.

Requests for enhancements are welcome - but the best is when people jump in and contribute in the areas that matter to them personally. If you feel a need, say, in better documentation, you can start working on our wiki, or on our help, and improve it - we are glad to help you get started. Then you would see yourself, that anyone wanting you to put your volunteer effort into, e.g., implementing a better installer instead of writing better documentation that matters to you personally, would be not quite correct :wink:

Just to make myself clearer (I realize that I may fail to express myself correctly): please do file enhancement requests. It is a great contribution itself. Just have correct expectations: writing such a request is expressing that there is a need in something, but not a guidance for anyone what to do. So they are wonderful source of information about the problems, which may help someone decide what to do next - but the asker should not assume any timely resolution of the request. Having correct expectation helps to avoid disappointments.

Obviously you miss MS-Excel.
If you expect LO to behave like Excel, you will never be satisfied. So my suggestion is to use Excel.

You are right - recording macros is limited in LO, the API is mostly completely different and not designed for a friendly impression on beginners, but this will not change quickly…

Welcome, @educmale !

I will not attempt to explain why this happened, why the macro recorder does not record what can be interpreted as normal code.

In short, "it just happened historically"

I know you are old school, you remember the first editions of Excel. You may also remember that before Excel-5, before the advent of VBA in 1993, macros for spreadsheets were written in a completely different way - a sequence of calls to special functions was recorded on a separate special sheet of the workbook … Don’t you remember? And rightly so, do not remember this Stone Age.

I will give one more link in addition to the ones already mentioned. This is a very old article - Sometimes the macro recorder fails. Pay attention to the last section (neither of the two links there worked for me).

Paolo Mantovani 16 years ago made an attempt to improve the situation you complained about. Perhaps somewhere in the archives of the Internet, the source codes of that project have been preserved? Perhaps you can use your experience and knowledge to continue this work?

@JohnSUN Discovered (maybe) something last night you and those references allude to; LO Macro tries to generate command lines (dispatches) and not the underlying code; which explains why I was so confused. I suspect that there is a depth to changing the perspective of Macro Recording that is way beyond one person’s (mine) skill set, and would take an awkwardly large number of contributors’ interest with an already existing knowledge of the entire LO api model. to maneuver “Macro” to the utility I was hoping for.

At the same time, I switched from Windows and MS Office to Linux and LibreOffice. I knew MS Office very well, including MS Access and Visio packages, I programmed in MS Access, Excel, Word, PowerPoint, Outlook. I am now working tightly with LO Calc and a little bit with Writer. It took me 2 years of active programming to understand what you are talking about. It’s all good now. Only it will take longer to get the information without a savvy macro recoder, but the forum is a help. Just don’t quit. The starting points have already been given to you.

1 Like