Free Republic
Browse · Search
General/Chat
Topics · Post Article

Skip to comments.

How to start writing macros in LibreOffice Basic
Opensource ^ | 2/8/18 | Lera Goncharuk

Posted on 02/09/2018 5:34:55 AM PST by markomalley

I have long promised to write about the scripting language Basic and creating macros in LibreOffice. This article is devoted to the types of data used in LibreOffice Basic, and to a greater extent, descriptions of variables and the rules for using them. I will try to provide enough information for advanced as well as novice users.

(And, I would like to thank everyone who commented on and offered recommendations on the Russian article, especially those who helped answer difficult questions.)

Variable naming conventions

Variable names cannot contain more than 255 characters. They should start with either upper- or lower-case letters of the Latin alphabet, and they can include underscores ("_") and numerals. Other punctuation or characters from non-Latin alphabets can cause a syntax error or a BASIC runtime error if names are not put within square brackets.

Here are some examples of correct variable names:

Note: In examples that contain square brackets, if you remove the brackets, macros will show a window with an error. As you can see, you can use localized variable names. Whether it makes sense to do so is up to you.

(Excerpt) Read more at opensource.com ...


TOPICS: Computers/Internet
KEYWORDS: basic; libreoffice; vba
Navigation: use the links below to view more comments.
first 1-2021-25 next last
For those who don't know it, LibreOffice is a complete Office Suite (Word Processor, Spreadsheet, Presentations, Drawing, and Database) that is an open source equivalent to Microsoft Office.

It is free and open source (as opposed to $70-160 for the cheapest version of MS Office) -- also available for Linux, Windows, and MacOS. For virtually any home user, LibreOffice works perfectly well for home users (and, if everybody in an office used it, for office users as well). If you are contemplating buying an MS Office license, I would highly encourage you to check out LibreOffice first.

This tutorial shows how to write macros to help automate recurring tasks in LibreOffice.

Disclaimer: I use both LibreOffice and MS Office on my computers. One of the primary reasons is that the VBA language used in MS Office is not fully compatible with the Basic language used by LibreOffice. (I also use Calligra Office, but that's another issue altogether)

1 posted on 02/09/2018 5:34:55 AM PST by markomalley
[ Post Reply | Private Reply | View Replies]

To: markomalley

I used to use GW Basic quite a bit to write utility programs I needed to process experimental data in college. Never did find a good replacement after about Windows 2000.

Can you point me toward something to replace it?

Thx, ‘Pod.


2 posted on 02/09/2018 5:40:04 AM PST by sauropod (I am His and He is mine.)
[ Post Reply | Private Reply | To 1 | View Replies]

To: markomalley

I use VBA to write stock trading and market analysis algorithms for Excel. Is the Basic language pretty similar to VBA?


3 posted on 02/09/2018 5:42:12 AM PST by RoosterRedux (Onward Christian Soldiers!)
[ Post Reply | Private Reply | To 1 | View Replies]

To: sauropod
Can you point me toward something to replace it?

Have you considered perl or python?

4 posted on 02/09/2018 5:43:52 AM PST by plsvn
[ Post Reply | Private Reply | To 2 | View Replies]

To: sauropod
I used to use GW Basic quite a bit to write utility programs I needed to process experimental data in college. Never did find a good replacement after about Windows 2000.

Have you looked at PC Basic? (last updated Jan 2018)

5 posted on 02/09/2018 5:45:32 AM PST by markomalley (Nothing emboldens the wicked so greatly as the lack of courage on the part of the good -- Leo XIII)
[ Post Reply | Private Reply | To 2 | View Replies]

To: rdb3; Calvinist_Dark_Lord; JosephW; Only1choice____Freedom; amigatec; Ernest_at_the_Beach; ...

6 posted on 02/09/2018 5:49:42 AM PST by ShadowAce (Linux - The Ultimate Windows Service Pack)
[ Post Reply | Private Reply | To 1 | View Replies]

To: RoosterRedux
I use VBA to write stock trading and market analysis algorithms for Excel. Is the Basic language pretty similar to VBA?

Have you looked at this resource? Converting VBA to OpenOffice Basic.

Also there is a PDF that explains the porting process: Porting Excel/VBA to Calc/Star Basic

7 posted on 02/09/2018 5:50:57 AM PST by markomalley (Nothing emboldens the wicked so greatly as the lack of courage on the part of the good -- Leo XIII)
[ Post Reply | Private Reply | To 3 | View Replies]

To: markomalley

Thx much, Mark. Will look into that.


8 posted on 02/09/2018 5:52:39 AM PST by RoosterRedux (Onward Christian Soldiers!)
[ Post Reply | Private Reply | To 7 | View Replies]

To: plsvn

It’s been suggested to me. Haven’t investigated yet.


9 posted on 02/09/2018 6:15:13 AM PST by sauropod (I am His and He is mine.)
[ Post Reply | Private Reply | To 4 | View Replies]

To: markomalley

No but I will!


10 posted on 02/09/2018 6:15:40 AM PST by sauropod (I am His and He is mine.)
[ Post Reply | Private Reply | To 5 | View Replies]

To: markomalley

I use libreoffice for most things.

MS Office is better about label printing.

Fwiw, I despise printers to no end.


11 posted on 02/09/2018 6:50:44 AM PST by wally_bert (I didn't get where I am today by selling ice cream tasting of bookends, pumice stone & West Germany)
[ Post Reply | Private Reply | To 1 | View Replies]

To: RoosterRedux

Both are ‘Basic’, so yes


12 posted on 02/09/2018 7:00:40 AM PST by Pikachu_Dad ("the media are selling you a line of soap")
[ Post Reply | Private Reply | To 3 | View Replies]

To: RoosterRedux

I am not a programmer but do a lot of Linux scripting. This comparison might help to answer your questions:

https://eklausmeier.wordpress.com/2013/10/27/programming-in-excel-vba-compared-to-libreoffice-openoffice-calc/


13 posted on 02/09/2018 7:35:29 AM PST by taxcontrol (SStupid should hurt)
[ Post Reply | Private Reply | To 3 | View Replies]

To: taxcontrol

Thx much.


14 posted on 02/09/2018 7:46:34 AM PST by RoosterRedux (Onward Christian Soldiers!)
[ Post Reply | Private Reply | To 13 | View Replies]

To: markomalley

M4L
LibreOffice Basic


15 posted on 02/09/2018 8:06:53 AM PST by Scrambler Bob
[ Post Reply | Private Reply | To 1 | View Replies]

To: markomalley

LibreOffice gives me the only way to convert an Excel file to a PDF programmatically, at least somewhat painlessly.


16 posted on 02/09/2018 8:08:10 AM PST by dfwgator
[ Post Reply | Private Reply | To 1 | View Replies]

To: markomalley

bttt


17 posted on 02/09/2018 8:51:01 PM PST by Unrepentant VN Vet (...against all enemies, foreign or domestic...)
[ Post Reply | Private Reply | To 1 | View Replies]

To: wally_bert
Fwiw, I despise printers to no end.

I think everyone does.

18 posted on 02/11/2018 11:09:16 AM PST by zeugma (Power without accountability is fertilizer for tyranny.)
[ Post Reply | Private Reply | To 11 | View Replies]

To: wally_bert

I defense of paper and printers, I never heard of malware leaping from a printed document and infecting a computer. They can be read when the power is out and don’t disappear when your HD crashes. They are unaffected by EMP. They are not subject to bit rot. The failure modes of paper are well understood as are preventative measures. There really is a lot going for it.


19 posted on 02/11/2018 3:38:36 PM PST by beef
[ Post Reply | Private Reply | To 11 | View Replies]

To: zeugma

I can think of one type who loves a printer.

The special one who has a printer in their office or cube.

Heaven forbid if there is a problem and they have to walk 20 or 30 feet to a network printer. Some act like their firstborn has died.


20 posted on 02/11/2018 3:59:12 PM PST by wally_bert (I didn't get where I am today by selling ice cream tasting of bookends, pumice stone & West Germany)
[ Post Reply | Private Reply | To 18 | View Replies]


Navigation: use the links below to view more comments.
first 1-2021-25 next last

Disclaimer: Opinions posted on Free Republic are those of the individual posters and do not necessarily represent the opinion of Free Republic or its management. All materials posted herein are protected by copyright law and the exemption for fair use of copyrighted works.

Free Republic
Browse · Search
General/Chat
Topics · Post Article

FreeRepublic, LLC, PO BOX 9771, FRESNO, CA 93794
FreeRepublic.com is powered by software copyright 2000-2008 John Robinson