[Solved] Round() "not defined"

Creating a macro - Writing a Script - Using the API

[Solved] Round() "not defined"

Postby femgeek » Mon Feb 04, 2013 11:49 am

A Calc macro I've been tweaking for two days now has suddenly decided to start throwing a "Function or sub-procedure is not defined" error at me over a simple Round() function. It was working fine before, and now even a macro that's nothing but a Round() function will give me a runtime error.

I'm assuming this means something, somewhere went missing, but I have no idea what or where. I've already tried to uninstall OpenOffice, deleted all app data, and reinstalled, but no dice.

I've no idea where to even begin looking for a solution, and my Google-fu has failed me woefully.

Help? Ideas? Vague points? Condolences?
Last edited by femgeek on Mon Feb 04, 2013 1:41 pm, edited 1 time in total.
OpenOffice 3.4.1 on Windows 7 (64bit)
femgeek
 
Posts: 3
Joined: Mon Feb 04, 2013 11:25 am

Re: Round() "not defined"

Postby RoryOF » Mon Feb 04, 2013 12:11 pm

No matter what everyone thinks, reinstalling OpenOffice does not affect the User Profile. The first step for any fix for sudden OpenOffice peculiarities is to delete (if a beginner) or rename (if you have OpenOffice customisation) the User Profile. Details are at


[Tutorial] The OpenOffice User Profile
Apache OpenOffice 4.1.7 on Xubuntu 18.04.3 (mostly 64 bit version) and very infrequently on Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 29776
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Round() "not defined"

Postby femgeek » Mon Feb 04, 2013 12:51 pm

Sorry, should've been clearer! I did delete all the app data, including the user profile, as well as the folder in Programs just in case, before reinstalling OO. It seems to've been a clean reinstall -- my macro was gone, as were my keyboard shortcuts, etc. Still getting the same error. :(
OpenOffice 3.4.1 on Windows 7 (64bit)
femgeek
 
Posts: 3
Joined: Mon Feb 04, 2013 11:25 am

Re: Round() "not defined"

Postby B Marcelly » Mon Feb 04, 2013 1:27 pm

Hi,
femgeek wrote:A Calc macro I've been tweaking for two days now has suddenly decided to start throwing a "Function or sub-procedure is not defined" error at me over a simple Round() function. It was working fine before, and now even a macro that's nothing but a Round() function will give me a runtime error.

In OpenOffice Basic, Round() function does not exist.

Since your macro worked before :
- either it called a user-declared Function named as Round()
- or you have deleted the line Option VBAsupport 1 at top of the Basic module.
Bernard

OpenOffice.org 1.1.5 / Apache OpenOffice 4.1.1 / LibreOffice 5.0.5
MS-Windows 7 Home SP1
B Marcelly
Volunteer
 
Posts: 1160
Joined: Mon Oct 08, 2007 1:26 am
Location: France, Paris area

Re: Round() "not defined"

Postby femgeek » Mon Feb 04, 2013 1:40 pm

Aha! Didn't recall ever seeing the line "Option VBAsupport 1" at the top of the module, but I did realise I'd deleted the "REM ***** BASIC *****" line at the top. Fixed that, and it works like a charm.

Many thanks, B Marcelly. You're a Prinec(ess) among (wo)men! :D
OpenOffice 3.4.1 on Windows 7 (64bit)
femgeek
 
Posts: 3
Joined: Mon Feb 04, 2013 11:25 am

Re: Round() "not defined"

Postby andrew_p » Thu May 16, 2019 8:24 pm

B Marcelly wrote:In OpenOffice Basic, Round() function does not exist.

You can define your own Round(m, n) function in OpenOffice Basic, thus:
Code: Select all   Expand viewCollapse view
Function Round(m, Optional n)
   ' Round a number "m" to "n" decimal places
   ' If "n" isn't supplied, round to zero decimal places
   If IsMissing(n) Then n = 0
   Round = Int(m*10^n + .5)/10^n
End Function

If n<0 it will round to the left of the decimal point.
If n>0 it will round to the right of the decimal point.
If n=0 it will round down to zero decimal places.

The second parameter "n" is optional. If n is omitted, it behaves like Round(m, 0).
OOo 3.4 - Ubuntu Linux 10.04
User avatar
andrew_p
 
Posts: 2
Joined: Mon Nov 26, 2012 5:16 pm
Location: San Jose, California


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 4 guests