The craziest thing is that someone on another forum gave me a very simple example that works without a hitch. I copied the code and get the same error as mentioned before.
Copying others macro code without understanding it often leads to these kinds of errors. Part of the problem you are experiencing involves confusion over the word "form" because it can have multiple meanings. Base contributes to the problem by having a Forms area on the main database page. Actually, it should be Form Documents. Looking at the example you referenced,
MyLibrary is the name of a form document. A form document is a collection of 1 or more Forms. Macro code often is not portable when it is written to work with a specific form document. One clue is whenever
getByName() is used in the code you will likely have portability issues.
Looking at the example database you referenced, Open the form document
MyLibrary in the Edit/Design mode.
Near the bottom left of the screen is the Form Design toolbar.
Select the
Form Navigator (5th icon from the left) to open the Form Navigator dialog.
In the Form Navigator dialog looking at the structure of the form document notice that the control BookTitle appears inside the Form named MainForm.
I modified the macro code found at WebsiteButtons -> Module1 ->GoogleBookTitle to read:
Code: Select all
myLibraryForm = ThisComponent.Drawpage.Forms.getByName("MainForm")
Now when I press the Google button to the right of BookTitle my web browser opens to a results page of a Google search on the text entered in BookTitle.
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11