Noobie!
They are two different functions but because I collected them from Macro Management they came out in alphabetical order so the first half appears to be the second macro - F&R.
You might also consider that if you are writing macros (or learning to), you don’t really write most macros the way the recorder does. The recorder is based on UNO dispatching directly. A lot of that is hidden in modern LO BASIC macros. Read lots of newer macros online. It’s not quite like recording macros for Excel in VBA, which was a little more one-to-one. That said, the action macros–true ‘macro’ shortcuts–like you are showing here still DO tend to be dispatch-based. Sometimes instead of mimicking a user action, though, you can ask “where do the data I’m manipulating here fit into the LO API model?” and use a more direct (syntactically) approach. I.e. change what you want to change rather than effectively call up the dialog box that changes it. Andrew’s book is a little dated on this, dare I say, although a great resource nonetheless.
So it does, thanks.
Fortunately, I will always be doing it in small volumes on a regular basis because I could see the wheels turning when I fed it 3500 cells to play with. It’s probably my data structure though because all the cells are 3 colour conditional formatted. Any thoughts on the subject?
Dare I ask who Andrew may be?
Found it or not - Scandinavian keyboard, I get § or ½ so it’s perfect if I want to write new legislation for parliament.
I guess I’ll just have to paste @karolus tip somewhere I won’t forget it - or not post code
Yes, sorry…distracted. Had intended to provide a link. Another pretty good landing page is from Prahlad Yeri, Ten useful LibreOffice Macro Recipes - Prahlad Yeri.
That page also links to LibreOffice 7.2 SDK - Examples, which usually links to pretty ‘hip’ macros.
@erAck Are there any thoughts on why the recorded macro only processed the paste special and completely ignored the find & replace? is it as I suspected, the second parameter of the wizard defaults to null even though I set it in my recording? Clearly, my macro would be redundant anyway because the CT2N extension copes admirably - but I can’t learn if I have to guess at the outcome.
Recorded macros (recorded user interface dispatches) act as a makeshift until someone writes a true macro recorder. IF (and only if) you are familiar with the application itself and with the user interface, you can achieve amazing things with dispatches.
[Solved] Request for comments: Favorite Recorded Calc Macros
However, most “Excel experts” start recording macros whenever a grid appears on screen without knowing much about the thing they hack upon.
Macros in general, but dispatches in particular, are very capable of destroying your document when you run the code against the wrong sheet or document.
You can inspect the CT2N extension’s source code to learn how to do things, it’s written in Basic.
I think I need to learn more than two new things today
Good call, I hadn’t realised I could do that. Thanks
If you really want to learn programming macros, MRI would be the essential helping tool which also includes something like a real macro recorder writing valid code in five langauges based on the interaction with the tool.
[Tutorial] Introduction into object inspection with MRI
However, if you do your first steps in programming within the API of LibreOffice, then you are certainly in the wrong class. IMHO, this API is radically unfriendly to beginners. And StarBasic as a language throws you back into the 90ies with no ties to the present programming universe. You end up with skills that are hardly transferable to anything beyond Libre/OpenOffice which is a petty and a waste of energy.
There is an old quote from Edsger Dijkstra: “It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: As potential programmers they are mentally mutilated beyond hope of regeneration.”
I guess the third thing I learned is… not to bother - leave it to the pros
The language you choose does not matter. The major obstacle on your path is the thing you are talking to. The complexity of UNO makes a steep learning curve even for experienced professionals. Learning how to program UNO with StarBasic is like practicing for a pilots license on a 747 (UNO) with a garden chair as a pilot seat (StarBasic).
Has convinced me that I should stop trying to put bells and whistles on a simple spreadsheet - that already performs the function for which it was created - in order to save myself a dozen keystrokes a day.
LO BASIC is designed on Visual Basic for Applications (VBA) which is designed on Visual Basic 6, which was released in 1998 or so. But I wouldn’t be quite as negative about learning LO BASIC macro programming as Villeroy is. If you stick to the kind that Prahlad Yeri shows and other examples where, say, you just are looping through …getCellByPosition(rowIndex,columnIndex) using nested loops to change something, etc., it isn’t that bad. In other words, you can do a lot by code-puppying, and if you learn along the way, so much the better. IMHO it beats trying to invent in-cell formulas with arrays, etc., that verge on madness. I’ve definitely gone down that rabbit hole, and probably will again, but would much rather program in BASIC.
Also, IMHO, all (serious) programming languages are what they are. If you know what is going on in the background, use COBOL, Fortran, Wolfram, BASIC, C++, C#, Java, whatever. You just use the tool in front of you. As Villeroy points out, it’s the UNO API that is daunting. BASIC isn’t so bad.
But Villeroy’s advice seems sound. If what you want to do is start to learn how to program against an API, learning C# on the .Net Framework/WinApps or javascript against the Google Sheets API, etc., would offer lots more bang for the buck.
StarBasic and its IDE is more like the first appearance of VBA in MS Office 95. MS Office 97 had the complete object orientation, predefined object events, code editor with auto-complete easy-peasy add-in development and all the other gimmicks that do not exist in StarBasic.
Will definitely give that some more consideration.
@joshua4 & @Villeroy Thanks for your insights. I’m probably also gonna download “Clash of the Titans”, to relieve some of my intensity over “squeezing the last drop” from my limited knowledge of the inbuilt functions.
Still learning at least two new things every day - the hard way.