Bug 34763 - calc: [EASY HACK] Copy method missing for 'sheets' collection
Summary: calc: [EASY HACK] Copy method missing for 'sheets' collection
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
3.3.0 release
Hardware: x86 (IA32) Linux (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-26 05:56 UTC by Bob Harvey
Modified: 2011-05-05 12:59 UTC (History)
0 users

See Also:
Crash report or crash signature:


Attachments
The complete macro code. (2.96 KB, text/plain)
2011-02-26 05:56 UTC, Bob Harvey
Details
recorded macro to copy three sheets. (1.28 KB, text/plain)
2011-02-26 09:08 UTC, Bob Harvey
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Bob Harvey 2011-02-26 05:56:18 UTC
Created attachment 43853 [details]
The complete macro code.

I have written a rather pleasing little macro in excel, which works fine in Windows/MSoffice.

It doesn't run in Libreoffice/calc.  I can step through the code with the debugger, and it is the copy method in the code below that causes the problem:
i = Sheets.Count
Sheets(Array("Specimen data", "Specimen pu", "Specimen eng.")).Copy After:= _
        Sheets(i)

Executing this line causes a dialogue which says
BASIC runtime error.
'423'
Copy


The help says that 423 means "423 Property or method not found" so I assume you have not yet implemented sheets(index).copy

I thought this bug report might help improve the next generation.

(The macro in full is attached for reference.  I had to set the lowest security level to run it at all)
Comment 1 Bob Harvey 2011-02-26 09:08:41 UTC
Created attachment 43857 [details]
recorded macro to copy three sheets.

Just for grins, I tried it in windows with LibreOffice 3.3.1.
The error message was rather more baffling:
BASIC runtime error
'1'
Type:com.sun.star.uno.RuntimeException
Message:[mcsi_uno bride error] UNO type of C++ exception unknown:"std.__non_rti_object",RTTI-name=".?AV__non_rtti_object@std@"!

I can't tell you what the runtime error 1 means in windows, because een though I have installed the help page download, the programme insists on going to the web, where it says "Sbasic/start" has no text.


Fur further grins I have recorded a macro using calc to do the same thing, copy three sheets, and I have to say that the syntax of what I got back (attached, LibreOffice3_macro.txt) is rather non-obvious compared to what I was working with in MSoffice.  I can't see any way to write code portable between the two.
Comment 2 Noel Power 2011-02-28 03:47:12 UTC
make this into an easy hack, details http://wiki.documentfoundation.org/Development/Easy_Hacks#VBA_support_add_support_for_Worksheets.Copy hopefully someone will pick this up.

regarding the output from the libreoffice macro recorder we don't recommend using that at all ( I thought in fact it was disabled by default )
Comment 3 Bob Harvey 2011-03-01 04:54:56 UTC
@Noel Power:
Thanks for escalating that.  Much Appreciated.

One thing that is of importance in the excel implementation is that relative addressing is preserved during the copy process.  If, for example, a cell or a graph in sheet2 references sheet1, performing a copy of two sheets means that the cell or graph in sheet4 ends up referencing sheet3 - not the original sheet.

And, yes, I had to turn the macro recorder on in order to fiddle with it.
Comment 4 Markus Mohrhard 2011-05-05 12:59:40 UTC
fixed in LibreOffice 3.4 by commit f96c5afd276287d896760e11542918e679069b8c