I need the selected row from a table control in a writer document. Using this, I can see if a row is selected at all:
Option Explicit
Sub GetSelected
Dim oForm As Object
Dim oSelectedRows As Object
Dim oTable As Object
Dim oTableView As Object
Dim iStart As Integer
Dim iEnd As Integer
Dim myTotal As Integer
Dim n As Integer
Dim i As Integer
REM Get access to the current form
oForm = ThisComponent.Drawpage.Forms.getByName(“Today_Roster”)
REM Get Table Grid Control
oTable = oForm.getByName(“available_offenders”)
Rem Get View for Grid Control
oTableView = ThisComponent.getCurrentController().getControl(oTable)
Rem Get array of selected rows
oSelectedRows = oTableView.getSelection()
because the UBOUND of oSelectedRows will be -1 if one is not.
However, after this I can’t figure out how to actually get any data from the control.
Also, these tables are based on Base Queries, so after I submit the commands I will need to refresh the tables. For example, I will be submitting a SQL command and base the where
clause off the ID of the selected row.
I’d appreciate even a partial answer, it’s probably simple but I can’t implement any logic until I can figure out how to move forward on this.
Note: The macro needs to be executed in writer.