Table Control in Sheet

I have a table control named ‘tbb’ inserted in a Sheet
it has a column named ‘c1’
In my macro the ‘getColumns()’ is not recognised
error says “property or method not found”

sh = thiscomponent.Sheets.getByName(“Sheet1”)
dp = sh.DrawPage

msgbox dp.forms(0).getByname(“tbb”).getColumns().getByName(“C1”)

Any ideas ?

In principle everything can be read, written or edited with a macro. Opinions may vary whether that is advisable, and gives a sturdy and professional result. Some items require a tremendous in dept knowledge. On the other hand there are topics in this forum that deal with window size. Here is an extract giving you the user current screen dimensions before calling the macro.Preformatted text

Sub window_size()

Dim oDoc, oWindow As Object
Dim H, W As integer

oDoc = thiscomponent
    oWindow=oDoc.CurrentController.Frame.ContainerWindow
H = oWindow.getSize().Height()
W = oWindow.getSize().Width()

Print H,W

End Sub

oh thanks indeed
this gives the current dimension of the Libre application and not the users window screen
but anyway do you know about adding minimize maximize buttons to the Dialog ?

The table control has no method getColumns. Surprisingly, it does not have any columns. It is a container for “normal” form controls text box, check box, list box etc. linked to a database column. The database column is provided by the form control’s form which is connected to a database’s table or query. Each form control (text, check, list etc.) attached to a table control is displayed in multiple instances row by row.
It may be possible to attach a table control to a dialog and programmatically fill it with columns that are not linked to anything but I’ve never tried any such stunt in 15 years using Open/LibreOffice with databases.

This thread is about a table control, you should make a new thread for screen/application size. It might well be that you have to introduce handmade buttons and subsequent size settings in macro code yourself.

thanks
i got the solution to display tabular data without a database link
the GridControl does it

Hello,

It is quite unusual to have a table control in a Calc sheet. A table control is usually associated with a database table. There you would use getColumns to access a field in the database table so based upon your question the error is correct.

To get at the column c1 in the control use this line

controlColumn = dp.forms(0).getByname(“tbb”).getByName(“c1”)

Not certain what you may be attempting. Possibly explain further.

1 Like

It would be convenient for me to insert a Table Control into the dialog and place in it data that is not related to the database, but, for example, read from a file. Could you give examples of macros that work with Table Control without linking it to database?

@shma_lo1

This is a different question. See How to use a gridcontrol in a dialog

Thanks a lot

Text File → Database → Database document → Form with table control. A database form can be attached to a a Writer document ebeeded in the database document, a stand-alone Writer document or a spreadsheet.
No silly Basic code needed. Just use the given objects.

https://forum.openoffice.org/en/forum/viewtopic.php?t=23727&p=108195#p108195
https://forum.openoffice.org/en/forum/viewtopic.php?t=21099&p=96427#p96427

Thanks, but for some reason I don’t want to use database.

Thanks @Ratslinger. I’m used to VBA coding and just started using Libre
I’m developing a Tool at work and cannot use the Database since we do not have JRE installed there.
I need to display a Form for user input and submission
The reason i don’t want to use a Dialog is that it doesn’t seem to have options like a minimize/maximize button like the VBA Userform does using Win32
Also i prefer to display the Form in full screen fitted to user screen size,
which i didn’t see possible here in Libre
Im not sure if those 2 things can be achieved in Libre.
So, for now I’m inserting the required controls in the Sheet to serve as a Form.
In the Form I need something like a multi column Table with headers,
like the Listbox control in VBA
Dont want to use the spreadsheet for this.
It has to be a proper separate object in the Sheet
This ListBox will be filled with values programatically
If not possible I shall just have to drop that Listbox feature in the Tool

I’m also having trouble automating the IE Browser which is part of the Tool functionality. For eg. the ‘document.getElementByID’ comes up as not supported.
Tried the ‘VBA support’ command in my code too.
Im ok to use javascript/VBScript here but not aware if this can be done without any additional system installations

Let me know what options I’ve got please

@bloke

See comment by @Villeroy - no need for JRE. Will not be able to use wizards or Report Builder but should do what you want.

Dialog was only noted because of other poster.

CTRL + Shift + J toggles Fullscreen mode

Don’t know anything about IE Browser you speak of and the rest is vague to me.

thanks @Ratslinger
when i try creating a new database it gives the JRE error
i need to be able to create a database and its tables for the Tool to work

the Full screen is needed for me to be able to programmatically arrange the position and size of the controls in the Dialog accordingly to fit the entire Dialog nicely.
what i need for this, is to find the user screen size at runtime so i can set the Dialog to that fixed size - which i couldn’t find a way to get

You can’t do that in LibreOffice unless you invest an unreasonable amount of time and effort. You have to do that with MS Office/VBA until you overcome the whole concept of office application as a development suite. Professional applications do not use any spreadsheets except for data export or reporting.

@bloke

Had no JRE error with text/spreadsheet Base file. If you must have a database and no JRE needed, use something like PostgreSQL, MariaDB, MySQL, or Firebird server. There is also Firebird embedded but has issues of its’ own. Again no JRE means no wizards and no Report Builder.

Also don’t know why you are back to a dialog. First of all the controls will not be data aware. All must be done by you through code. Gave you info to show full screen for LO modules.

I am not back to the Dialog
im just making it clear why the option you suggested for maximizing the Dialog is not enough for me. cntrl shift .
which is why im going with the Sheet embedded controls idea
anyway yes thanks i’ll see about the JRE

@bloke

CTRL + Shift + J is not for dialogs and did not state anywhere that it was. Did state it was for Fullscreen and it was for LO modules. Did you not try it?

Dialog questioned because of this statement:

i need to be able to create a database and its tables for the Tool to work
the Full screen is needed for me to be able to programmatically arrange the position and size of the controls in the Dialog accordingly to fit the entire Dialog nicely.

' Full screen dialogue
' Author: @rami  https://forumooo.ru/index.php/topic,8122.15/msg,54900.html  
Sub DlgDisplay
Dim oWindow, winSize, oDlg, oDlgModel, newSize, w%, h%, bt
oWindow = CreateUnoService("com.sun.star.awt.Toolkit")
winSize = oWindow.ActiveTopWindow.Size
oDlgModel = CreateUnoService("com.sun.star.awt.UnoControlDialogModel")
oDlgModel.setPropertyValue("Title", "Dialog - Large Window")
oDlg = CreateUnoService("com.sun.star.awt.UnoControlDialog")
oDlg.setModel(oDlgModel)
oDlg.createPeer(oWindow, null)

newSize = oDlg.convertSizeToLogic(winSize, 17)   '17 or 18
w = newSize.Width
h = newSize.Height

oDlgModel.setPropertyValue("Width", w-1)
oDlgModel.setPropertyValue("Height", h-1)

bt = oDlgModel.createInstance("com.sun.star.awt.UnoControlButtonModel")
bt.setPropertyValues(Array("Height","PositionX","PositionY","PushButtonType","Label","Width"),Array(15, w-50, h-20, 1, "Step", 40))
oDlgModel.insertByName("StepButton",bt)
oDlg.execute()
End Sub