Comments on: Writing a Macro in LibreOffice Calc: Getting Started https://www.debugpoint.com/writing-a-macro-in-libreoffice-calc-getting-started/ Linux and Dev Portal Tue, 20 Dec 2022 04:47:57 +0000 hourly 1 By: Alex DS https://www.debugpoint.com/writing-a-macro-in-libreoffice-calc-getting-started/#comment-423 Wed, 21 Jun 2017 02:16:00 +0000 http://www.debugpoint.com/?p=449#comment-423 Same thing with 4 lines only

sub Teste
mysheet = thiscomponent.currentcontroller.getactivesheet()

cella1 = mysheet.getcellrangebyname(“a1”)

cellA1.setstring(“Hello world”)
msgbox(“Process completed”)

end sub

]]>
By: Adriel Shawn https://www.debugpoint.com/writing-a-macro-in-libreoffice-calc-getting-started/#comment-281 Fri, 29 Apr 2016 00:48:00 +0000 http://www.debugpoint.com/?p=449#comment-281 HI. im a newbie in libre basic calc. i have a program that will copy the highlighted row to another sheet. but my problem is how can i determine if the cell have data. because whats heppening here is my program is just replacing the 2nd data that i transfer.

i would like to know the function for detecting if the cell have data if so go to next line. thanks in advance.

#HelpMeSensei

]]>
By: Kesri_Lion https://www.debugpoint.com/writing-a-macro-in-libreoffice-calc-getting-started/#comment-242 Thu, 10 Mar 2016 07:08:00 +0000 http://www.debugpoint.com/?p=449#comment-242 In reply to Arindam Giri.

Thnk you Mr. Giri,
I thought libreoffice macro language is VB only
Thnks for clarification that This is not VB but Its slimier to VB 🙂

]]>
By: Arindam Giri https://www.debugpoint.com/writing-a-macro-in-libreoffice-calc-getting-started/#comment-241 Thu, 10 Mar 2016 07:06:00 +0000 http://www.debugpoint.com/?p=449#comment-241 In reply to Vishal Jagani.

Yes.

]]>
By: Vishal Jagani https://www.debugpoint.com/writing-a-macro-in-libreoffice-calc-getting-started/#comment-240 Thu, 10 Mar 2016 07:00:00 +0000 http://www.debugpoint.com/?p=449#comment-240 In reply to Arindam Giri.

So these two language is fine to write macro in libreoffice right?

]]>
By: Arindam Giri https://www.debugpoint.com/writing-a-macro-in-libreoffice-calc-getting-started/#comment-239 Thu, 10 Mar 2016 06:53:00 +0000 http://www.debugpoint.com/?p=449#comment-239 In reply to Vishal Jagani.

You can use these languages to write macros in LibreOffice: Basic (similar to VB), Python

]]>
By: Vishal Jagani https://www.debugpoint.com/writing-a-macro-in-libreoffice-calc-getting-started/#comment-238 Thu, 10 Mar 2016 06:45:00 +0000 http://www.debugpoint.com/?p=449#comment-238 In reply to Arindam Giri.

Hey ca you pls tell us that which language are use for Libreoffice macro , Is it VB script or any other language
pls specify

]]>
By: Arindam Giri https://www.debugpoint.com/writing-a-macro-in-libreoffice-calc-getting-started/#comment-231 Wed, 17 Feb 2016 02:13:00 +0000 http://www.debugpoint.com/?p=449#comment-231 In reply to Jan Rolih.

Is this your entire macro? And at which line you are getting error?

]]>
By: Jan Rolih https://www.debugpoint.com/writing-a-macro-in-libreoffice-calc-getting-started/#comment-230 Tue, 16 Feb 2016 18:47:00 +0000 http://www.debugpoint.com/?p=449#comment-230 Hi, i am really new to basic. I am trying to make a macro, so when the dropdown menu looses focus, macro executs. The code is supposed to write chosen integer(id) into another temp table.
I get this error
BASIC runtime error.
Sub-procedure or function procedure not defined.

and the code:

sub idVzacasno
dim document as object
dim scv as object
dim macro as object
document = ThisComponent.CurrentController.Frame
svc = createUnoService(“com.sun.star.sheet.FunctionAccess”)
makro(“INSERT INTO zacasna(id) SELECT id_Reverz FROM Reverz;”)

end sub

If someone has any idea what i am doing wrong please help.

]]>
By: Nicola Floris https://www.debugpoint.com/writing-a-macro-in-libreoffice-calc-getting-started/#comment-225 Tue, 29 Dec 2015 18:17:00 +0000 http://www.debugpoint.com/?p=449#comment-225 In reply to Arindam Giri.

Amazing, i can save a lot of time and a lot of space with this 🙂
I am also rewriting the whole macro because using the arrays i can use a smarter way to obtain things done 😉
Thank you very much

]]>
By: Arindam Giri https://www.debugpoint.com/writing-a-macro-in-libreoffice-calc-getting-started/#comment-224 Tue, 29 Dec 2015 17:27:00 +0000 http://www.debugpoint.com/?p=449#comment-224 In reply to Nicola Floris.

You can use img_arr(6) to refer any individual items inside an array.

]]>
By: Nicola Floris https://www.debugpoint.com/writing-a-macro-in-libreoffice-calc-getting-started/#comment-223 Tue, 29 Dec 2015 17:09:00 +0000 http://www.debugpoint.com/?p=449#comment-223 In reply to Arindam Giri.

This is great!

then i could just write this

Dim img_arr(49)

for i=1 to 49

img_arr(i) = Foglio3.getCellbyPosition(12,i+1).String

next

and the job is done, to call a position on an array should i use

img_arr(6) or img_arr6 ?

]]>
By: Arindam Giri https://www.debugpoint.com/writing-a-macro-in-libreoffice-calc-getting-started/#comment-222 Tue, 29 Dec 2015 16:44:00 +0000 http://www.debugpoint.com/?p=449#comment-222 In reply to Nicola Floris.

You should use array. Instead of declaring 49 variables, declare an array of size 49. Then you can refer them via subscript. Like this:

Dim my_arr(49)

for i=1 to 49

my_arr(i) = “anything you want ” & i

next

after this execution, your array should contain value like this::

my_arr(1) = anything you want 1

my_arr(2) = anything you want 2

my_arr(3) = anything you want 3

my_arr(49) = anything you want 49

Array concept: https://msdn.microsoft.com/en-us/library/wak0wfyt.aspx

]]>
By: Nicola Floris https://www.debugpoint.com/writing-a-macro-in-libreoffice-calc-getting-started/#comment-221 Tue, 29 Dec 2015 16:14:00 +0000 http://www.debugpoint.com/?p=449#comment-221 In reply to Arindam Giri.

Well basically i need to state a lot of variables to be able to call them later where needed

FineURL1 = Foglio3.getCellbyPosition(12,2).String
FineURL2 = Foglio3.getCellbyPosition(12,3).String
FineURL3 = Foglio3.getCellbyPosition(12,4).String
…….
FineURL47 = Foglio3.getCellbyPosition(12,48).String
FineURL48 = Foglio3.getCellbyPosition(12,49).String
FineURL49 = Foglio3.getCellbyPosition(12,50).String

my macro is very long just because i have a lot of variable to state, i know there could a shorter way but i still need to think about it xD

]]>
By: Arindam Giri https://www.debugpoint.com/writing-a-macro-in-libreoffice-calc-getting-started/#comment-220 Tue, 29 Dec 2015 04:23:00 +0000 http://www.debugpoint.com/?p=449#comment-220 In reply to Nicola Floris.

Yes it is possible but that depends what you want to achieve. Say you are creating multiple images at runtime with dynamic file name as you said – image1, image2 etc. Then you can do something like this:

Dim i, c

for i=1 to 10

next

]]>
By: Nicola Floris https://www.debugpoint.com/writing-a-macro-in-libreoffice-calc-getting-started/#comment-219 Mon, 28 Dec 2015 18:57:00 +0000 http://www.debugpoint.com/?p=449#comment-219 Is it possible to put a variable in the variable name?
For example, i have
Image1
Image2
Image3
Image4

Can i state something to change the number in the variable name as the result of another variable?

]]>
By: Arindam Giri https://www.debugpoint.com/writing-a-macro-in-libreoffice-calc-getting-started/#comment-164 Thu, 14 May 2015 16:10:00 +0000 http://www.debugpoint.com/?p=449#comment-164 In reply to surja.

There may be some books, but I didn’t find any. If you want to learn, follow the tutorials in this site/search Google/forums etc.

]]>
By: surja https://www.debugpoint.com/writing-a-macro-in-libreoffice-calc-getting-started/#comment-161 Wed, 13 May 2015 03:50:00 +0000 http://www.debugpoint.com/?p=449#comment-161 Any book for beginners to learn macro programming for Calc?

]]>
By: João Alberto Garcia https://www.debugpoint.com/writing-a-macro-in-libreoffice-calc-getting-started/#comment-105 Fri, 09 Jan 2015 13:40:00 +0000 http://www.debugpoint.com/?p=449#comment-105 In reply to Arindam Giri.

Thank you, friend.

]]>
By: Arindam Giri https://www.debugpoint.com/writing-a-macro-in-libreoffice-calc-getting-started/#comment-103 Fri, 09 Jan 2015 03:36:00 +0000 http://www.debugpoint.com/?p=449#comment-103 In reply to João Alberto Garcia.

Jọo Alberto Garcia РThere are many ways to do that. Say, you want to copy cell contents B1 to A1. You can try this:

my_cell = ThisComponent.Sheets(0).getCellByPosition(1,0)
target_cell = ThisComponent.Sheets(0).getCellByPosition(0,0)
target_cell.Value = my_cell.Value

Value should be used for numbers, String should be used for string. So you need to put a check on what type of value the cell contains. Have a look here: http://www.debugpoint.com/2014/09/libreoffice-workbook-worksheet-and-cell-processing-using-macro/

]]>