[Solved] Crash when creating Basic macro

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
JeJe
Volunteer
Posts: 2779
Joined: Wed Mar 09, 2016 2:40 pm

Re: [Solved] Crash when creating Basic macro

Post by JeJe »

Same with your code, I click on No and then enter 99999 and get an overflow error, not a crash
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
mathieums
Posts: 12
Joined: Thu Apr 13, 2023 3:30 pm

Re: [Solved] Crash when creating Basic macro

Post by mathieums »

oh ok. I didn't know integer are that "small".

I normaly don't enter big numbers in there. I will revise my code in consequences. If I use it as initially intended it doesn't crash. I still can't edit my macro. A few months ago I made a backup of all my code in txt files, so this is were I sourced my code above.

If I open a new calc sheet, OpenOffice crash when I try to add the Module. After the crash the Module is there but I can't edit it, it makes OpenOffice crash once again :(
OpenOffice 4.1.14 on Windows 10 & Windows 11
mathieums
Posts: 12
Joined: Thu Apr 13, 2023 3:30 pm

Re: [Solved] Crash when creating Basic macro

Post by mathieums »

What happen when you get the overflow error??? Here OpenOffice crash, it does pretty much the same thing as when I try to edit my macro.
After the crash I have the "recovery" dialog.

Is there logs/crash logs/debug logs somewhere???
OpenOffice 4.1.14 on Windows 10 & Windows 11
User avatar
robleyd
Moderator
Posts: 5081
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: [Solved] Crash when creating Basic macro

Post by robleyd »

Integer variables can store any whole number between -32768 and 32767 - see Number Variables

You might use long integer instead?
Cheers
David
OS - Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 24.2.2.2; SlackBuild for 24.2.2 by Eric Hameleers
mathieums
Posts: 12
Joined: Thu Apr 13, 2023 3:30 pm

Re: [Solved] Crash when creating Basic macro

Post by mathieums »

robleyd wrote: Sat Apr 15, 2023 12:51 am Integer variables can store any whole number between -32768 and 32767 - see Number Variables

You might use long integer instead?
Wow! Ok I'll review and change my code. I wasn't aware at all. Thank you for the info!

Now, I just need to get access to it :lol:
OpenOffice 4.1.14 on Windows 10 & Windows 11
JeJe
Volunteer
Posts: 2779
Joined: Wed Mar 09, 2016 2:40 pm

Re: [Solved] Crash when creating Basic macro

Post by JeJe »

Yes its not the same thing that other languages use the 'integer' name for - its just 2 bytes, not the 4 bytes of a long.

The overflow error is just a msgbox.

You could try rewriting that bit of the code afresh in a new document to see if it works differently from pasting it - in case the problem derives from that.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
mathieums
Posts: 12
Joined: Thu Apr 13, 2023 3:30 pm

Re: [Solved] Crash when creating Basic macro

Post by mathieums »

I can try but I don't think it will give me access to the code :(

I have many files with many macros. If I don't edit them, just use the file and execute my macros normally it's all fine. I wanted to fine tune one of my macro and this is when I noticed that OpenOffice crash when I try to open the editor. I didn't even had a chance to view the code.

A new file with empty basic macro doesn't work too :(

But yes I will make sure my use of integers are within the "limits" and update my code accordingly.
OpenOffice 4.1.14 on Windows 10 & Windows 11
mathieums
Posts: 12
Joined: Thu Apr 13, 2023 3:30 pm

Re: [Solved] Crash when creating Basic macro

Post by mathieums »

I tried downgrading Java but it didn't work. Like mentioned in this thread, it's a Windows problem. In safe mode everything works correctly.

Oh well. Thanks to everyone for trying to help me fix the problem :)
OpenOffice 4.1.14 on Windows 10 & Windows 11
JeJe
Volunteer
Posts: 2779
Joined: Wed Mar 09, 2016 2:40 pm

Re: [Solved] Crash when creating Basic macro

Post by JeJe »

OO documents are zip files inside of which there's a Basic folder with the macro files - which are xml and can be edited in any text editor.

So you could unzip a document - edit the Basic xml files within it, eg change the library name from "Standard" if your code is in that library, and change the file extensions to those of normal exported libraries (.xml files to script.xlb and module1.xba etc). Then import the library into your user libraries - all without having to open the document.

Edit: if you don't have a zip utility which does it without renaming you just have to rename the file extension from .ods or .odt to .zip and then Windows can unzip it. Preferably using a copy of your file for this of course.
Last edited by JeJe on Sun Apr 16, 2023 2:02 am, edited 1 time in total.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
mathieums
Posts: 12
Joined: Thu Apr 13, 2023 3:30 pm

Re: [Solved] Crash when creating Basic macro

Post by mathieums »

JeJe wrote: Sun Apr 16, 2023 1:44 am OO documents are zip files inside of which there's a Basic folder with the macro files - which are xml and can be edited in any text editor.

So you could unzip a document - edit the Basic xml files within it, eg change the library name from "Standard" if your code is in that library, and change the file extensions to those of normal exported libraries (.xml files to script.xlb and module1.xba etc). Then import the library into your user libraries - all without having to open the document.
Wow that's really cool! Thank you for the info, I'll do that!
OpenOffice 4.1.14 on Windows 10 & Windows 11
JeJe
Volunteer
Posts: 2779
Joined: Wed Mar 09, 2016 2:40 pm

Re: [Solved] Crash when creating Basic macro

Post by JeJe »

I did a quick test - creating a sub in the standard library of a new document. Then saving and unzipping it.

I copied the Standard folder and renamed the folder - mynewlibrary or whatever using Notepad

Then all I had to do was change the file names

script-lb.xml file to script.xlb
Module1.xml to Module1.xba

and change library:name="Standard" to = "mynewlibrary" in the script file

Then successfully imported it into my user libraries.

With files with dialog controls pointing to subs in modules - you need to do a bit more work and change the path names of those from Standard to whatever. And location=document to location=application. Find/replace in Notepad will do that.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
mathieums
Posts: 12
Joined: Thu Apr 13, 2023 3:30 pm

Re: [Solved] Crash when creating Basic macro

Post by mathieums »

Duly noted! I did a quick test with 7zip on Windows and can easily access the content of the calc file. I'll try playing with this tomorrow.

Thank you again for your help :D
OpenOffice 4.1.14 on Windows 10 & Windows 11
Post Reply