Comments on: Form Processing with LibreOffice Calc Macro – Part 2 https://www.debugpoint.com/form-processing-with-libreoffice-calc-macro-part-2/ Linux and Dev Portal Tue, 19 May 2020 03:42:30 +0000 hourly 1 By: Nicola Floris https://www.debugpoint.com/form-processing-with-libreoffice-calc-macro-part-2/#comment-218 Sun, 27 Dec 2015 16:28:00 +0000 http://www.debugpoint.com/?p=1242#comment-218 In reply to Arindam Giri.

Brilliant!
I bet that in my actual code, i am writing too simple and long 😀
But it’s my first project ever, even if long, at least it should work

Thank you, really

]]>
By: Arindam Giri https://www.debugpoint.com/form-processing-with-libreoffice-calc-macro-part-2/#comment-217 Sun, 27 Dec 2015 16:07:00 +0000 http://www.debugpoint.com/?p=1242#comment-217 In reply to Nicola Floris.

Something like this:

Dim i

For i=0 to 9
cmbBox1.addItem(Sheet4.getCellbyPosition(0,i).String,i+1)
Next

]]>
By: Nicola Floris https://www.debugpoint.com/form-processing-with-libreoffice-calc-macro-part-2/#comment-216 Sun, 27 Dec 2015 15:45:00 +0000 http://www.debugpoint.com/?p=1242#comment-216 In reply to Arindam Giri.

What do you mean loop? i just wrote this and it works:

cmbBox1.addItem(Sheet4.getCellbyPosition(0,0).String,1)
cmbBox1.addItem(Sheet4.getCellbyPosition(0,1).String,2)
cmbBox1.addItem(Sheet4.getCellbyPosition(0,2).String,3)
cmbBox1.addItem(Sheet4.getCellbyPosition(0,3).String,4)
cmbBox1.addItem(Sheet4.getCellbyPosition(0,4).String,5)
cmbBox1.addItem(Sheet4.getCellbyPosition(0,5).String,6)

………until 10

is there another faster way? XD

]]>
By: Arindam Giri https://www.debugpoint.com/form-processing-with-libreoffice-calc-macro-part-2/#comment-215 Sun, 27 Dec 2015 15:30:00 +0000 http://www.debugpoint.com/?p=1242#comment-215 In reply to Nicola Floris.

You can either use Range or individual cells – but for both, you have to run a loop for each item. Getting the data from Range would be bit complicated because Range processing in LibreOffice is complex. I would recommend to run a loop for each item and put it in combobox.

In case you are wondering, you can get the range values using below. Range returns a 2D array with format my_data(row,col)

my_range = ThisComponent.Sheets(0).getCellRangebyName(“A1:A10”)
my_data = my_range.getDataArray()

]]>
By: Nicola Floris https://www.debugpoint.com/form-processing-with-libreoffice-calc-macro-part-2/#comment-214 Sun, 27 Dec 2015 14:03:00 +0000 http://www.debugpoint.com/?p=1242#comment-214 In reply to Arindam Giri.

Thanks for the quick reply, now it works perfectly 🙂
What i’m trying to do is for example, list each cell in A1:A10 from sheet3 as an option in the combo box.
Should i use a range or specify every cell?

]]>
By: Arindam Giri https://www.debugpoint.com/form-processing-with-libreoffice-calc-macro-part-2/#comment-213 Sun, 27 Dec 2015 13:27:00 +0000 http://www.debugpoint.com/?p=1242#comment-213 In reply to Nicola Floris.

You are very very close.

If your cell at position 0.0 contains character, use this:
cmbBox1.addItem(oCell.String,1)

If your cell at position 0.0 contains numeric, use this:
cmbBox1.addItem(oCell.Value,1)

You need to specify LO the contents, not the entire cell.

For more details on Cell contents type, read here:
http://www.debugpoint.com/2015/02/deleting-all-types-of-contents-from-calc-range-using-macro/

]]>
By: Nicola Floris https://www.debugpoint.com/form-processing-with-libreoffice-calc-macro-part-2/#comment-212 Sun, 27 Dec 2015 12:53:00 +0000 http://www.debugpoint.com/?p=1242#comment-212 Hello
i looked everywhere on OO wiki and forum but i cannot find a working way to populate my ComboBox with single cells or a range, for example:
oCell = ThisComponent.Sheets(3).getCellbyPosition(0,0)
cmbBox1.addItem(oCell,1)
I also tried using an array but i always says Object variable not set

PS. thanks for the guides, very useful 🙂

]]>
By: Arindam Giri https://www.debugpoint.com/form-processing-with-libreoffice-calc-macro-part-2/#comment-211 Mon, 14 Dec 2015 10:26:00 +0000 http://www.debugpoint.com/?p=1242#comment-211 In reply to Uroš Grum.

You are welcome!

]]>
By: Uroš Grum https://www.debugpoint.com/form-processing-with-libreoffice-calc-macro-part-2/#comment-210 Mon, 14 Dec 2015 10:24:00 +0000 http://www.debugpoint.com/?p=1242#comment-210 In reply to Arindam Giri.

Thank you ! you helped me a lot, i just cant seem to be able to find a properly written example, and belive me i tried searching a lot, i think i actually found this function but example was written porly and i probably messed up and tought it wasnt right.
Thanks aggain

]]>
By: Arindam Giri https://www.debugpoint.com/form-processing-with-libreoffice-calc-macro-part-2/#comment-209 Mon, 14 Dec 2015 10:18:00 +0000 http://www.debugpoint.com/?p=1242#comment-209 In reply to Uroš Grum.

To select any item inside a ListBox by using “index” – use “selectItemPos” method. See below.

lstBox1.selectItemPos( 0, True )

0 = the first entry would be selected, you can count as per your need starting from 0 as first.
True = it would be selected

]]>
By: Uroš Grum https://www.debugpoint.com/form-processing-with-libreoffice-calc-macro-part-2/#comment-208 Mon, 14 Dec 2015 09:23:00 +0000 http://www.debugpoint.com/?p=1242#comment-208 In reply to Uroš Grum.

Ok i have found one solution :
ListBox1.selectItem(“value not index”,True) i have no idea what does the bollean value do but would still like to know how to select by index.

]]>
By: Uroš Grum https://www.debugpoint.com/form-processing-with-libreoffice-calc-macro-part-2/#comment-207 Mon, 14 Dec 2015 08:49:00 +0000 http://www.debugpoint.com/?p=1242#comment-207 Hello!
This site has helped me before so i decided i would ask you for help aggain, i cant seem to find a property for setting the default selection in listbox, after i populate my listbox i would like to set item from the list as selected with code and i just spent an hour on the web trying to figure it out but none of the examples worked.

]]>
By: Soka Wakata https://www.debugpoint.com/form-processing-with-libreoffice-calc-macro-part-2/#comment-169 Tue, 19 May 2015 19:00:00 +0000 http://www.debugpoint.com/?p=1242#comment-169 Great Article. Thx for sharing the Macro Way under LibreOffice 🙂

]]>