[Solved] BASIC macro button anomaly

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
Rotnbair
Posts: 12
Joined: Wed Aug 23, 2023 10:01 pm

[Solved] BASIC macro button anomaly

Post by Rotnbair »

I recently started learning macro BASIC programming and have written several for a Calc spreadsheet, executed by pushbuttons. I have 2 very similar macros which function as designed; the issue is the different statuses of their pushbuttons on completion. I have attached text files of both.

When the CleanUp macro runs, the final instruction locates the cursor at cell C1 for another round of input; entering data in cell C1 works fine. The Copy30 macro runs fine, same final instruction, but after completion its pushbutton has a dashed-line rectangle superimposed on it---the CleanUp button has no such rectangle. The cursor is again located at cell C1, but if the user attempts to enter data in the cell, pressing the Enter key runs the macro again. To release(?) the button, the user must click on a different cell, not necessary after CleanUp is run. (Neither pushbutton is located in or near the cell C1.)

Obviously I don't understand what makes the 2 buttons different. Any enlightenment would be greatly appreciated. Thanks.
Attachments
X Copy30.txt
(2.65 KiB) Downloaded 345 times
R CleanUp.txt
(4.07 KiB) Downloaded 355 times
Last edited by floris v on Wed Dec 20, 2023 10:18 pm, edited 2 times in total.
Apache OpenOffice 4.1.14
Windows 11
JeJe
Volunteer
Posts: 2785
Joined: Wed Mar 09, 2016 2:40 pm

Re: BASIC macro button anomaly

Post by JeJe »

If you post a document with the buttons and code in rather than text files it will make it easier to look at and we can see the whole thing.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Rotnbair
Posts: 12
Joined: Wed Aug 23, 2023 10:01 pm

Re: BASIC macro button anomaly

Post by Rotnbair »

I see your point. I can upload the 100kb file, but the macro code is in My Macros/Standard/Module 1 so it won't be included. I wanted the macros attached to the sheet, since I run it on 2 machines, but when I try to put one in aCalc.ods/Standard/Module 2, the program blows up with "Due to an unexpected error, OpenOffice crashed." This happens every time.
Apache OpenOffice 4.1.14
Windows 11
JeJe
Volunteer
Posts: 2785
Joined: Wed Mar 09, 2016 2:40 pm

Re: BASIC macro button anomaly

Post by JeJe »

You're asking everybody to recreate what you have... create a document, rename the sheets, fill in some data blah blah... before they can look at it... and then guess about buttons.

I've done it (attached with your code) and for me, no crash. No idea what you buttons are or how they connect to it... they're not included.
Attachments
Untitled 1.ods
(11.43 KiB) Downloaded 354 times
Last edited by JeJe on Thu Aug 24, 2023 12:24 am, edited 1 time in total.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Rotnbair
Posts: 12
Joined: Wed Aug 23, 2023 10:01 pm

Re: BASIC macro button anomaly

Post by Rotnbair »

I ask the moderator to close this thread.
Apache OpenOffice 4.1.14
Windows 11
JeJe
Volunteer
Posts: 2785
Joined: Wed Mar 09, 2016 2:40 pm

Re: BASIC macro button anomaly

Post by JeJe »

Why do you want that? Have you solved the problem?
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
User avatar
Zizi64
Volunteer
Posts: 11364
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: BASIC macro button anomaly

Post by Zizi64 »

Here is JeJe's sample file with two buttons on the first sheet. And the macros are embedded in the file, and assigned to the renamed buttons. Not need to rename the buttons, and not need to rename them to the names of the subroutines, just assign the subs to some Event of the control elements (buttons)

I hahe edited your file in my LibreOffice 7.5.5 therefore the file format maybe has changed to the ODF 1.3 Extended.
Untitled 1_with_Buttons.ods
(12.73 KiB) Downloaded 364 times
Your macros works in my LO 7.5.5 on the JeJe's sample data.
Rotnbair, please upload YOUR sample file here.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
Rotnbair
Posts: 12
Joined: Wed Aug 23, 2023 10:01 pm

Re: [Solved] BASIC macro button anomaly

Post by Rotnbair »

Thanks for the help. I reorganized the macros in the sheet in a major way and the issue disappeared on its own.

By the way, I finally figured out a way to include macros in the Calc spreadsheet document. I had to delete the default library "my macros/standard/module 1" first, then create one in the sheet.
Apache OpenOffice 4.1.14
Windows 11
User avatar
floris v
Volunteer
Posts: 4431
Joined: Wed Nov 28, 2007 1:21 pm
Location: Netherlands

Re: [Solved] BASIC macro button anomaly

Post by floris v »

Rotnbair wrote: Wed Dec 20, 2023 8:27 pm (...) By the way, I finally figured out a way to include macros in the Calc spreadsheet document. I had to delete the default library "my macros/standard/module 1" first, then create one in the sheet.
There is no need to do that. You can save your own macros in the "my macros/standard/module 1" so that they are available for all of your documents as long as you open them on the pc where the macros are saved. If you want to save the macro only in one particular document, just select the item at the bottom of the dialog box, with the Calc document icon, see screenshot.
Schermafdruk van 2023-12-20 20-52-54.png
Schermafdruk van 2023-12-20 20-52-54.png (24.54 KiB) Viewed 2397 times
OpenOffice 4.1.11 on Ubuntu; LibreOffice 6.4 on Linux Mint, LibreOffice 7.6.2.1 on Ubuntu
If your problem has been solved or your question has been answered, please edit the first post in this thread and add [Solved] to the title bar.
Nederlandstalig forum
Rotnbair
Posts: 12
Joined: Wed Aug 23, 2023 10:01 pm

Re: BASIC macro button anomaly

Post by Rotnbair »

Thanks for the reply.

Ah yes, I did what you suggest for a long time. Since I work on 2 or 3 different machines, it was a pain keeping the macros current on all machines. I could and did create the second module as in your graphic more than once, but then (multiple times, every time) attempting to save a macro to the new spreadsheet module would crash OpenOffice. I have a few Calc spreadsheets, each with its own specific macros, so not having "my macros/standard/module 1" causes me no difficulties and improves portability.

Rather than give up, I decided on the drastic deletion of "my macros/standard/module 1" on a machine, to see if I could then store macros in the spreadsheet module (which worked). I then opened that spreadsheet on a different machine, and both the spreadsheet and OO modules worked fine. But the next time that different machine rebooted, OO reverted to not allowing both modules to contain macros, so I deleted "my macros/standard/module 1" on that one to get to the spreadsheet module macros.

I am open to improvement, so if you can tell what I am doing wrong, I would appreciate the help.
module.png
module.png (16.97 KiB) Viewed 2354 times
Apache OpenOffice 4.1.14
Windows 11
Post Reply