Access Table Control Element with OOo Basic

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
bolaabola
Posts: 3
Joined: Wed Mar 26, 2008 11:42 pm

Access Table Control Element with OOo Basic

Post by bolaabola »

Can anyone please tell how to access Table control element with OOo Basic?
To be more precise, I want to access column values in table control.
Can't find anywhere.
QuazzieEvil
Volunteer
Posts: 283
Joined: Tue Dec 04, 2007 6:38 pm
Location: Houston, TX

Re: Access Table Control Element with OOo Basic

Post by QuazzieEvil »

you can access it by name from the form. the columns in the table control are also accesible by name

example:

Code: Select all


TableControl=Form.getByName("MyTableControl")
Col1=TableControl.getByName("Col1")
Col2=TableControl.getByName("Col2")
REM and so forth.
bolaabola
Posts: 3
Joined: Wed Mar 26, 2008 11:42 pm

Re: Access Table Control Element with OOo Basic

Post by bolaabola »

Thanks for reading the post and answering.

What about the values of cell in that table?
For example, to access value of text box I use: oBox.Text = "some text"
What would be the property to access value of each cell.
Or possibly there is property to access values of all cells in certain column?
QuazzieEvil
Volunteer
Posts: 283
Joined: Tue Dec 04, 2007 6:38 pm
Location: Houston, TX

Re: Access Table Control Element with OOo Basic

Post by QuazzieEvil »

cells in a table control are regular form controls. so you can access their content in the same way
ouchd'greyt
Posts: 28
Joined: Wed Jun 28, 2017 4:41 am

Re: Access Table Control Element with OOo Basic

Post by ouchd'greyt »

thank you guys for the code, but there's a message object variable not set. how can i set the form?
OpenOffice 4.1.2 on Windows 7
ouchd'greyt
Posts: 28
Joined: Wed Jun 28, 2017 4:41 am

Re: Access Table Control Element with OOo Basic

Post by ouchd'greyt »

I tried the code, but there was runtime error message says "object variable not set for this one

TableControl=Form.getByName("MyTableControl")

how to set with this one?
OpenOffice 4.1.2 on Windows 7
UnklDonald418
Volunteer
Posts: 1544
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Access Table Control Element with OOo Basic

Post by UnklDonald418 »

runtime error message says "object variable not set for this one

TableControl=Form.getByName("MyTableControl")
Have you defined Form?
How are you invoking the macro?
For instance if you are using a button Event then something like

Code: Select all

Form = oEvent.Soure.Model.Parent
might work.

If you are trying to access form controls you need to use an object inspection tool.
There is a tutorial on the MRI tool
viewtopic.php?f=74&t=49294
it has a handy feature, once you've navigated to the control or value you are seeking press <Ctrl>h and it will open a window showing code you can use in your macro.
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
ouchd'greyt
Posts: 28
Joined: Wed Jun 28, 2017 4:41 am

Re: Access Table Control Element with OOo Basic

Post by ouchd'greyt »

Hi UnklDonald418,

Thank you for your kindness..

It might help..
OpenOffice 4.1.2 on Windows 7
ouchd'greyt
Posts: 28
Joined: Wed Jun 28, 2017 4:41 am

Re: Access Table Control Element with OOo Basic

Post by ouchd'greyt »

QuazzieEvil wrote:you can access it by name from the form. the columns in the table control are also accesible by name

example:

Code: Select all


TableControl=Form.getByName("MyTableControl")
Col1=TableControl.getByName("Col1")
Col2=TableControl.getByName("Col2")
REM and so forth.

hi would like to know how about the acquiring the data or the details under that column? :mrgreen: :mrgreen:
OpenOffice 4.1.2 on Windows 7
UnklDonald418
Volunteer
Posts: 1544
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Access Table Control Element with OOo Basic

Post by UnklDonald418 »

If you were using the MRI tool to inspect Col1 you would be able to see all the available properties, Including
CurrentValue
DataField
Name
It would then be easy to make assignments such as:

Code: Select all

val1 = Col1.CurrentValue
You can also see a list of properties in the IDE by setting a Breakpoint and using the Watch tool.
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
Post Reply