Bug 81003 - BASIC runtime error. '380' Incorrect property value
Summary: BASIC runtime error. '380' Incorrect property value
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
3.3.3 release
Hardware: Other Windows (All)
: medium minor
Assignee: Not Assigned
URL:
Whiteboard: BSA
Keywords:
Depends on:
Blocks: Macro-StarBasic
  Show dependency treegraph
 
Reported: 2014-07-07 12:46 UTC by Bob
Modified: 2020-01-06 05:57 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
Very simple excel spreadsheet with VB macro (18.00 KB, application/vnd.ms-excel)
2014-07-07 12:46 UTC, Bob
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Bob 2014-07-07 12:46:42 UTC
Created attachment 102371 [details]
Very simple excel spreadsheet with VB macro

Problem description: 
I get BASIC runtime error. '380' Incorrect property value when a simple spreadsheet calls this function in an xls spreadsheet (using LO 4.2.5.2 on Win7 Home Prem)

Rem Attribute VBA_ModuleType=VBAModule
Option VBASupport 1
Option Explicit


Global Const DAYS_PER_YEAR As Double = 365.25
Global Const MONTHS_PER_YEAR As Double = 12#


Public Function getCompound(initValue As Double, initDate As Date, finalDate As Date, intRate As Double) As Double
    Dim adjPeriod As Double
    adjPeriod = (finalDate - initDate) / DAYS_PER_YEAR
    getCompound = initValue * (1 + intRate) ^ adjPeriod
End Function

The macro works if I change VBASupport to 0 but the VBASupport line is added by LO and it is impractical to expect users to change code every time they open a Spreadsheet.

What is it actually objecting to?

The same spreadsheet works fine in OO 4.1.0 with Option VBASupport 1

Steps to reproduce:
Open attached spreaheet with LO Calc

Current behavior:
BASIC runtime error. '380' Incorrect property value


Expected behavior:
Correct execution of function as on Excel and OO calc 4.1
              
Operating System: Windows 7
Version: 4.2.5.2 release
Comment 1 tommy27 2014-07-21 18:30:57 UTC
I got that error message in each LibO version I tested, the oldest being LibO 3.3.3 and the newer being 4.4.0.0.alpha0+ (*)

(*) Build ID: b9dca968c6fd0ab5ca140c65b0e54d153cd34986
TinderBox: Win-x86@42, Branch:master, Time: 2014-07-18_22:51:20

I add BASIC expert to CC list to hear his opinion.

that file loads fine in MS Excel Viewer
Comment 2 Noel Power 2014-07-21 19:44:49 UTC
(In reply to comment #1)
> I got that error message in each LibO version I tested, the oldest being
> LibO 3.3.3 and the newer being 4.4.0.0.alpha0+ (*)
> 
> (*) Build ID: b9dca968c6fd0ab5ca140c65b0e54d153cd34986
> TinderBox: Win-x86@42, Branch:master, Time: 2014-07-18_22:51:20
> 
> I add BASIC expert to CC list to hear his opinion.
> 
> that file loads fine in MS Excel Viewer

the problem seems related to handling of the Date type (and specifically when that type is passed as a param to a formula) iirc there is some special handling or conversion for Dates in VBA mode (or something... tbh it's a long time since I looked at that stuff) If you rewrite the macro signature without the type specifier for the Date types it should work in both excel and libreoffice

e.g.

Public Function getCompound(initValue As Double, initDate, finalDate, intRate As Double) As Double

so initDate & finalDate are treated as Variant types
Comment 3 Bob 2014-07-22 15:24:36 UTC
Thanks,

The work around solves the problem in my test case and in my real, much more complicated spreadsheet.

I can now suggest LO as valid alternative to excel for my users who dont have MS Office.

Of course it would be good for the underlying problem to to be fixed so that others don't experience the same problem
Comment 4 QA Administrators 2015-09-04 02:49:44 UTC Comment hidden (obsolete)
Comment 5 Buovjaga 2015-11-30 13:55:38 UTC
Still confirmed.

Minor due to workaround.

Win 7 Pro 64-bit Version: 5.2.0.0.alpha0+
Build ID: a7c3a2a9be83686657c06f37d521f9f6d2004ddd
Threads 4; Ver: Windows 6.1; Render: default; 
TinderBox: Win-x86@39, Branch:master, Time: 2015-11-28_04:39:18
Locale: fi-FI (fi_FI)
Comment 6 QA Administrators 2017-01-03 19:36:43 UTC Comment hidden (obsolete)
Comment 7 tommy27 2017-01-03 23:01:24 UTC
bug still present in LibO 5.2.4.2
Comment 8 QA Administrators 2018-01-04 03:34:47 UTC Comment hidden (obsolete)
Comment 9 QA Administrators 2020-01-05 03:48:29 UTC Comment hidden (obsolete)
Comment 10 himajin100000 2020-01-06 05:57:35 UTC
When I changed the given code as follows,

Public Function getCompound(initValue As Double, initDate, finalDate, intRate As Double) As String' Calculate and apply compound interest for the period specified
    Dim adjPeriod As Double
    adjPeriod = (finalDate - initDate) / DAYS_PER_YEAR
    getCompound = TypeName(initDate)
    
End Function

I mean,

1. Removed the type declaration from initDate and finalDate
2. I changed the returned value to TypeName of initDate
3. Changed the return type to String

The returned value on the cell where this function is used was "Range"

https://opengrok.libreoffice.org/xref/core/sc/source/core/tool/interpr4.cxx?r=6873e0a9#3304