Bug 111303 - BASIC error '91' on iCount = ActiveChart.SeriesCollection.Count
Summary: BASIC error '91' on iCount = ActiveChart.SeriesCollection.Count
Status: RESOLVED WORKSFORME
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
5.4.0.3 release
Hardware: x86-64 (AMD64) Windows (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
: 152604 (view as bug list)
Depends on:
Blocks:
 
Reported: 2017-08-03 07:31 UTC by schlebe
Modified: 2022-12-20 02:27 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Calc file with macros (67.26 KB, application/vnd.ms-excel.sheet.macroEnabled.12)
2017-08-03 07:31 UTC, schlebe
Details
debug_document_2.xlsm (19.54 KB, application/zip)
2018-10-29 14:01 UTC, Stéphane Aulery
Details

Note You need to log in before you can comment on or make changes to this bug.
Description schlebe 2017-08-03 07:31:42 UTC
Created attachment 135092 [details]
Calc file with macros

I use for the first time a macro defined in Excel 2007.
The macro crash on the following line

iCount = ActiveChart.SeriesCollection.Count

with the following error's message translated from french

BASIC Execution Error '91'
Object variable not defined.

I have replaced iCount = ... by iCount = 0 and the line is executed, so that I'm pretty sure that the problem is caused by the expression ActiveChart.

I have tried to use IMMEDIATE Window on LibreOffice but I don't find it on LibreOffice !!!

I have attached my original file without personal DATA.
The macro is started in calling "ComputeTableMensuelle" and crash when line 
iCount = ... is executed in CleqrChqrt() function.


'*************************************************************************
'* ClearChart
'*************************************************************************

Sub ClearChart()
    Sheets(xSheet + 1).Select
    
    Application.ScreenUpdating = False
    'ActiveSheet.ChartObjects(1).Activate

    iCount = ActiveChart.SeriesCollection.Count
    Do While iCount > 1
        ActiveChart.SeriesCollection(2).Delete
        iCount = iCount - 1
    Loop
    
    Sheets(xSheet + 2).Select
    
    Application.ScreenUpdating = False
    'ActiveSheet.ChartObjects(1).Activate
    
    iCount = ActiveChart.SeriesCollection.Count
    Do While iCount > 1
        ActiveChart.SeriesCollection(2).Delete
        iCount = iCount - 1
    Loop
    
    Sheets(1).Select
End Sub
Comment 1 Xisco Faulí 2017-08-03 08:51:28 UTC
Hello schlebe,
Could you please share the steps to run the macro? Every time I try to run it I get: 
BASIC runtime error.
Sub-procedure or function procedure not defined.
Comment 2 schlebe 2017-08-03 10:08:54 UTC
Hello Xisco,

I have downloaded the attachment posted by me to be in same situation that you.

Then to start the macro, I click on

1. Tools\Macros\Execute menu
2. a tree with 3 possiblitlies is displayed
3. I open the node ReleveCompteurs.ELECTRICITE.forLO.xlsm
3. I open the node VBA project
4. I double click on node "Module1"
5. I double click on ComputeTableMensuelle macro in right panel

... and the macro run and crash.

I hope that than can help you.

Bye
Comment 3 Xisco Faulí 2017-08-03 16:13:34 UTC Comment hidden (obsolete)
Comment 4 schlebe 2017-08-10 19:03:10 UTC
I have installed last version 6.0.0.0.alpha0+ and I have tested the macro with sheet 1 filled with correct values.

The program doesn't crash ... it is OK

... BUT the program doesn't fill correctly the cells in others sheets like it make on Excel.

For each sheet after first sheet, the program create a sheet with 2 tables and a sheet with a Chart representing these 2 tables.

For each sheet with 2 tables, the program
1. clear the column representing the data of year 2017
2. fill the column of year 2017

When I analyze the result, I can see that the 2017 columns seems to be cleaned

BUT the 2017 column are always EMPTY.

When I try to Debug the program to give you more information ... the program crash ... no chance.

So I think (but I'm not sure) that the 6 alpha version recognize the ActiveChart object but for unknown reasons doesn't make correctly the following actions because the 2017 columns are all emtpy.
Comment 5 Xisco Faulí 2017-11-13 18:10:14 UTC
(In reply to schlebe from comment #4)
> I have installed last version 6.0.0.0.alpha0+ and I have tested the macro
> with sheet 1 filled with correct values.
> 
> The program doesn't crash ... it is OK
> 
> ... BUT the program doesn't fill correctly the cells in others sheets like
> it make on Excel.
> 
> For each sheet after first sheet, the program create a sheet with 2 tables
> and a sheet with a Chart representing these 2 tables.
> 
> For each sheet with 2 tables, the program
> 1. clear the column representing the data of year 2017
> 2. fill the column of year 2017
> 
> When I analyze the result, I can see that the 2017 columns seems to be
> cleaned
> 
> BUT the 2017 column are always EMPTY.
> 
> When I try to Debug the program to give you more information ... the program
> crash ... no chance.
> 
> So I think (but I'm not sure) that the 6 alpha version recognize the
> ActiveChart object but for unknown reasons doesn't make correctly the
> following actions because the 2017 columns are all emtpy.

Closing as RESOLVED WORKSFORME then. Please report another issue for the cells not filled
Comment 6 Stéphane Aulery 2018-10-29 14:00:06 UTC
Hello,

I can reproduce this bug on Windows 7 with LO 6.0.6.2 (x64).

In fact there are 4 bugs in this example:

To reproduce execute sub ComputeTableSolaire() in Module1 of the VBAProject.

a) It seems that ActiveChart is not implemented at all (423 runtime error).

b) In sheet "Graphics Solaire" the graph is an object but in sheet "Cumul Solaire" the graph is really a graph. You can see it in the object navigator. If I insert a graph in the sheet "Graphics Solaire" with the menu Insert > Graph..., an object is inserted, not a graph. ChartObjects.Count return 0 on sheet "Graphics Solaire" and 1 on sheet "Cumul Solaire".

c) The name property on a Chart object return an empty string.

d) An chart object has a SeriesCollection collection but using it raise an 91 runtime error.

Regards,

-- 
Stéphane Aulery
Comment 7 Stéphane Aulery 2018-10-29 14:01:12 UTC
Created attachment 146137 [details]
debug_document_2.xlsm
Comment 8 Stéphane Aulery 2018-10-29 14:02:04 UTC
debug_document_2.xlsm is a minimal example of the four bugs.
Comment 9 Xisco Faulí 2018-12-03 13:36:09 UTC
Hello Stéphane Aulery,
the original report was about a crash, which is no longer reproducible in 6.0.0.0.alpha0+ as mentioned in comment 4.
Please, report the problems mentioned in comment 6 in a new bug -> https://bugs.documentfoundation.org/enter_bug.cgi?product=LibreOffice&format=guided
Closing as RESOLVED WORKSFORME
Comment 10 Stéphane Aulery 2022-12-20 02:27:30 UTC
*** Bug 152604 has been marked as a duplicate of this bug. ***