Error at getbyname in the LoadDialog function

When trying to run the very simple script:

Dim Dialog1 as object
Sub Dialog1Show   
      BasicLibraries.LoadLibrary("Tools")
      oDialog1 = LoadDialog("Standard", "Dialog1", DialogLibraries)
      oTextField = oDialog1.getControl("dte") 'Textbox to display date'
      oTextField.settext Format (Date,"mm/dd")
      oDialog1.Execute()

End Sub

I got an error at the LoadDialog function.

Function LoadDialog(Libname as String, DialogName as String, Optional oLibContainer)
Dim oLib as Object
Dim oLibDialog as Object
Dim oRuntimeDialog as Object
	If IsMissing(oLibContainer ) then
		oLibContainer = DialogLibraries
	End If
	oLibContainer.LoadLibrary(LibName)
	oLib = oLibContainer.GetByName(Libname)
	oLibDialog = oLib.GetByName(DialogName)
	oRuntimeDialog = CreateUnoDialog(oLibDialog)
	LoadDialog() = oRuntimeDialog
End Function

When the function gets to the line oLibDialog = oLib.GetByName(DialogName) I get an error:

BASIC runtime error. An exception
occurred Type:
com.sun.star.container.NoSuchElementException
Message: .

But I cannot figure out why. The same script seems to be working for many people so I am at lost here… My libreoffice is running under Ubuntu 16.04

Any help will be appreciated.

Thanks.

I fixed your formatting.

Same error here trying to start the AltSearch extension.

Environment: OS X 10.9.5, Libreoffice 6.1.6.3, JaveRE Oracle 1.8.0_20, AltSearch 1.4.2

I would even be able to pay a bill for fixing this, working for a non-profit organisation that is interested in the quality of free and open source software.

@fabriosan please learn to use the toolbar in a question/answer to format your code properly. It is difficult at best to comprehend. Also, not sure why you posted as Wiki - this limits your capabilities and does not allow recognition to those taking the time to answer your questions.

The library to load is where your dialog resides.

Sub openAboutDialog
	Dim Dlg As Object
	DialogLibraries.LoadLibrary("Standard")
	Dlg = CreateUnoDialog(DialogLibraries.Standard.NAME_OF_YOUR_DIALOG)
	Dlg.Execute()
	Dlg.dispose()
End Sub

Much more detailed information on libraries & macros can be found in OOME - pdf here.

When the function gets to the line

 oLibDialog = oLib.GetByName(DialogName) 

I get an error:

BASIC runtime error. 
An exception occurred Type: com.sun.star.container.NoSuchElementException  
Message: .

This says that oLib does not contain the object specified by the string in DialogName.

Since you are setting oLib with this:

oLibContainer.LoadLibrary(LibName)
oLib = oLibContainer.GetByName(Libname)

Then I would use MRI to investigate where things are going wrong. Try putting mri oLibContainer before these lines and then use MRI to drill down into the mess. In other words in mri select the methods and then select LoadLibrary and enter your library name. Then select the method getByName and see if what you want is there.

I’ve found getByName in MRI to be very handy to confirm where I think I am in the object mesh.