I completely stripped LibreOffice and all user data from my PC and reinstalled. So, a completely fresh 18.104.22.168 install. As a test I then I created an empty Calc sheet. In Macros organiser I created a new Module 1 within the sheet (not in MyMacros) as I want to be able to send the sheet to another PC with a working macro. I then created a dialog under the new “sheet” module. I then wrote this code:
Sub Main Dim Dialog as Object Dim Label as Object GlobalScope.BasicLibraries.LoadLibrary("Tools") Dialog = LoadDialog("Standard", "Dialog1") Label = Dialog.GetControl("Label1") Label1.Text = "YES!" End Sub
Running the macro from a double click event on the sheet - I get:
BASIC runtime error.
An exception occurred
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
It fails at oLibDialog = oLib.GetByName(DialogName)
I have been informed that the only way to send a Calc sheet with working macros (and dialogs) is to put all macros and dialogs “under” the sheet in the Macro organiser - but I constantly find (even with this utterly fresh test approach) that it fails, it appears to require everything to be in MyMacros to work but if I do that the sheet is empty of macros and dialogs when sent (emailed).
I really need to be able to distribute my work to other PCs but this is preventing me. Any pointers please as to what I am doing wrong.
[erAck: edited to properly mark code blocks as code; please do so by selecting a code block and hitting Ctrl+K which indents by 4 spaces to format, thanks.]