Bug 70754

Summary: Object's references by set expression are messed
Product: LibreOffice Reporter: Eugenij Shkrigunov <eshkrig>
Component: BASICAssignee: Not Assigned <libreoffice-bugs>
Status: RESOLVED DUPLICATE    
Severity: normal    
Priority: medium    
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
Crash report or crash signature: Regression By:
Attachments: example demonstrating problem

Description Eugenij Shkrigunov 2013-10-22 10:01:02 UTC
Created attachment 87975 [details]
example demonstrating problem

Hi!
Sorry for my English.

LibreOffice-4.1.2.3 has trouble that not exist in previous versions (at least LibreOffice-4.0.4.2).

Workbook of 2 sheets: "Sheet1" and "Sheet2". Cell "A1" of "Sheet1" contains value 42. Object's reference mySheet is messed after adding sheet. First MsgBox correctly reports value 42, but second don't.

Option VBASupport 1
Option Explicit

Dim mySheet

Sub Main
	Set mySheet = Sheets("Sheet1")

	MsgBox("Before copy sheet: " + mySheet.Cells(1, 1).Value)

	Sheets("Sheet2").Copy Before:=Sheets("Sheet1")

	MsgBox("After copy sheet: " + mySheet.Cells(1, 1).Value)
End Sub

Code like above is from file generated by another program beyond our control.
Attachment contains sample file. Try to run macro bug_demo.ods -> Standard -> Module1 -> Main.
Comment 1 Eugenij Shkrigunov 2013-10-23 07:41:56 UTC

*** This bug has been marked as a duplicate of bug 70079 ***