Sub Print3 ' it doesn't work
Dim oDoc As Object
Dim oDrawpage As Object
Dim oForm As Object
Dim sName As string
oDoc = thisComponent
oDrawpage = oDoc.drawpage
oForm = oDrawpage.forms.getByIndex(0).getByIndex(0).getByIndex(6)
sName = oForm.getByName("State").text
print sName
End Sub
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
[Tutorial] Introduction into object inspection with MRI
Do NOT access form elements by index unless you are very sure that you never change anything on these forms.
Instead of pulling forms from the DrawPage you could also follow an event driven programming approach. Every form event passes over some kind of event struct where the Source element refers to the calling object.
Sub ControlEvent(oEv)
oCallingThing = oEv.Source
oForm = oCallingThing.getParent()
REM in rare cases where the caller is embedded in a table grid:
oForm = oCallingThing.Parent.getParent()
Sub SubFormEvent(oEv)
oSubForm = oEv.Source
oForm = oEv.getParent()
Sub FormEvent(oEv)
oForm = oEv.Source
This way you are right in the middle of where the music plays without crossing the entire hierarchy
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Thanks @JeJe e @Villeroy, I understand that the getByIndex () method does not give fixed results as I thought.
I also discovered a new way: I will study MRI to learn how to use it well. Thanks again !!