[Solved] Sub-Procedure not defined error only when ...

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
aej18
Posts: 3
Joined: Wed Nov 20, 2013 9:42 pm

[Solved] Sub-Procedure not defined error only when ...

Post by aej18 »

Obviously, this is a very simple bit of code, tied to a button in my spreadsheet. If I close the document and re-open it, then try to click any of my buttons, I get the "Sub-procedure or procedure function not defined" error. If I then make any change in the code, undo it, then hit "save", I can go back into my spreadsheet and hit the button and everything works exactly the way it is supposed to.

Is there something not getting loaded when I open my spreadsheet? If so, what do I need to do to get it to load all of my macros/functions without me manually saving all of them off?

Code: Select all

Sub Kills()
 Sheets("druids").Range("b3").Value = Sheets("druids").Range("b3").Value + 1
End Sub
Last edited by aej18 on Wed Nov 20, 2013 11:40 pm, edited 2 times in total.
OpenOffice 4.0.1
Windows 7 Ultimate 64-bit
User avatar
Villeroy
Volunteer
Posts: 31363
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Sub-Procedure not defined error only when document re-op

Post by Villeroy »

(1) You moved the sub into another module or (2) the module into another library or (3) you saved the library in a document which is not your current document.
Turn on edit mode and try pointing the button to the right sub. In case of (3), document macros apply to their containing document only. They should be stored in templates.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
aej18
Posts: 3
Joined: Wed Nov 20, 2013 9:42 pm

Re: Sub-Procedure not defined error only when document re-op

Post by aej18 »

I've tried assigning the button again to no avail. If I re-assign it to the proper macro, I will continue getting the error until I make a change and hit save.

The path displayed at the bottom for each of the macros is "(document name).ods.Standard.(macro name)". Is this wrong? They all dis play under the "Standard Folder" when I go to the organize macros tab.
OpenOffice 4.0.1
Windows 7 Ultimate 64-bit
User avatar
Villeroy
Volunteer
Posts: 31363
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Sub-Procedure not defined error only when document re-op

Post by Villeroy »

OK, I see. It is a VBA macro. VBA is not supported.

Code: Select all

Sub Kills()
sh = ThisComponent.Sheets("druids")
cell = sh.getCellRangeByName("b3")
cell.Value = cell.Value + 1
End Sub
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
aej18
Posts: 3
Joined: Wed Nov 20, 2013 9:42 pm

Re: Sub-Procedure not defined error only when document re-op

Post by aej18 »

Ok, thanks for the help. I find it interesting that it works perfectly when I run it manually. I'll change all my code over and hope it works.
OpenOffice 4.0.1
Windows 7 Ultimate 64-bit
User avatar
Villeroy
Volunteer
Posts: 31363
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Sub-Procedure not defined error only when document re-op

Post by Villeroy »

aej18 wrote:Ok, thanks for the help. I find it interesting that it works perfectly when I run it manually. I'll change all my code over and hope it works.
Interesting, indeed. There is something like a highly experimental "VBA compatibility mode", but you can not count on that. It's a big waste of developers time.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Post Reply