Ask Your Question
0

Error at getbyname in the LoadDialog function

asked 2017-06-16 22:40:41 +0100

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

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.

edit retag flag offensive close merge delete

Comments

I fixed your formatting.

EasyTrieve gravatar imageEasyTrieve ( 2017-06-17 04:53:01 +0100 )edit

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.

mois gravatar imagemois ( 2019-06-12 12:02:15 +0100 )edit

2 Answers

Sort by » oldest newest most voted
0

answered 2017-06-16 23:54:55 +0100

Ratslinger gravatar image

@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.

edit flag offensive delete link more
0

answered 2017-06-17 19:45:25 +0100

EasyTrieve gravatar image

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.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2017-06-16 22:40:41 +0100

Seen: 405 times

Last updated: Jun 17 '17