user829755
user829755

Reputation: 1588

#NAME? error after opening spreadsheet with macro

I created and saved a spreadsheet that uses a macro for an interpolation task. When I open the document again all the cells calling the function are shown as #NAME? although the document still seems to contain the macro: When I open Tools | Macros | Organize Macros... | LibreOffice Basic Macros | (the document) | util | Module1 and click 'Edit' I can edit the source code as before.

Does anybody know what's wrong? How can I recover my file? I switched the security setting to 'Low (not recommended)', just be be sure, but only after having created and saved the file.

Upvotes: 3

Views: 2418

Answers (3)

François Breton
François Breton

Reputation: 1398

Remember to allow macros to run : Tools, Options, Security, Macro Security, Trusted Sources (or security level).

Upvotes: 0

Dan Dascalescu
Dan Dascalescu

Reputation: 151702

I had the same problem with a macro defined with Sub Foo. I changed that to public function Foo, and it worked.

NB: after 20 years of software development, the LibreOffice API is the crappiest one I've had the "pleasure" of working with. The documentation is horrible, spread all over the place, littered with Uyghur, or completely missing. The LibreOffice macro IDE is also extremely unhelpful.

Upvotes: 0

Axel Richter
Axel Richter

Reputation: 61915

In libreoffice or openoffice basic it is not possible to run a user defined function, which is stored in a library except the Standard libraries, as formula in a cell. Although it is possible to have functions stored in libraries, the UDFs have to be in the Standard libraries. They (the UDFs) then of course can call functions in libraries if those libraries are loaded.

UDFs in libreries

The UDF can be called in a cell as =UDF(). The UDF2 can also be called in a cell as =UDF2(). It then loads the library "util", if it is not already loaded yet, and returns the result of utilUDF().

See also http://www.openoffice.org/documentation/manuals/userguide3/0312CG3-CalcMacros.pdf#7 "Write your own functions" page 7 to 12.

Greetings

Axel

Upvotes: 2

Related Questions