Rewrite base Macros for standalone writer forms

I have a lo base form with a simple basic macro (reload the form after doing a selection)
When exporting the base form to a standalone writer form I copied and reconnected the related macro.
However, It seems the way of access, the structure and the naming of the form elements changed.
Can someone please point me to a tutorial / a way on how I change my macro to gain same functionality again. Thank you!

This is the (base) macro I use:

Sub executeList
Dim oEingabe, oAusgabe
oFrm = ThisComponent.DrawPage.Forms.getByName(“MainForm”)
oAusgabe = oFrm.getByName(“AnzeigeTafel”)
oAusgabeAuswahl = oFrm.getByName(“AnzeigeAuswahl”)
oAusgabeAuswahl.Commit
oAusgabeAuswahl.Parent.updateRow()
oAusgabe.reload
End Sub

You know the (german) guide for Base by Robert Großkopf ?

Most of the problems appear with “ThisComponent”.
I prefer to start macros with the event:

SUB executeList(oEvent AS OBJECT)
oAusgabeAuswahl = oEvent.Source.Model
oAusgabeAuswahl.Commit
oAusgabeAuswahl.Parent.updateRow()
oAusgabeAuswahl.Parent.Parent.getByName("AnzeigeTafel").reload
END SUB

Haven’t written much content about external forms in Base Handbuch. I’m using only internal forms here.

This issue appears with writer, not with base. The macro is working perfect with base: It simply reloads the form after a selection has been made.
The document / name / method structure seems to be different somehow.

Where did you save the macro. Hope in the Writer file as you saved the other in Base file.

Forms in a Base file are included Writer documents. So there shouldn’t be any difference.

No, certainly not. Why do you believe that? Just have a look at the form navigator.

The macro is correctly part of the writer file. It fails with a structural error, seems to be the forms object.

Gruß / Regards

Walter Werner

was zum teufel ist ein “structural error”? wenn du dich nicht klar ausdrücken kannst, dann lass das programmieren sein!

This is the error message I get, sorry for posting it late:
“BASIC runtime error. Property or method not found: getByName.”

That’s because the component you have found isn’t the form.

Install something like XRay to get the properties of oFrm.

@RobertG
I’m sorry, your solution throws another error:
“BASIC runtime error.
An exception occurred
Type: com.sun.star.container.NoSuchElementException
Message: at /Users/cloph/build/workdir/UnoApiHeadersTarget/udkapi/normal/com/sun/star/container/NoSuchElementException.hdl:18.” in the line before the END SUB

Open you form document.
Open the form navigator.
Show a screenshot of the form navigator with all forms and subforms visible.

See the form navigator:
Bildschirmfoto 2025-01-01 um 14.30.43
Bildschirmfoto 2025-01-01 um 14.30.23
The form navigator is identical to the one in the base document.

Having a look at the screenshot and see:

  • No form “MainForm” visible like it should in your macro.
  • No element “AnzeigeAuswahl” visible.
  • No element “AnzeigeTafel” visible.
    Which element in your screenshot should start executing the macro?
    Which form should be saved?
    Which form should be reloaded?
    And, by the way: Why didn’t you ask in the German part of ask.libreoffice.org? All members, who are answering in this thread, are also posting in German.

I’m sorry for the question, thanks to @RobertG I discovered that I copied the wrong macro.
Copying the right macro solved the issue.
Please accept my apologies and thank you very much for your support.
Walter.