Excel crashes opening XLSRW-generated file

Questions and answers on how to use XLSReadWriteII 3/4/5.
Post Reply
Roman
Posts: 1
Joined: Mon Aug 08, 2011 11:02 am
Location: Russia

Excel crashes opening XLSRW-generated file

Post by Roman »

Hello

I create a small XLS file with the XLSReadWriteII component. The file only contains a button and a macro to execute when the button is pressed.
When I try to open the resulting file in Excel, it crashes immediately after opening.

This problem has been disturbing me from time to time when opening such files. After upgrading to registered version 4.0 of the component, crashes became permanent. The same Excel at the same PC successfully opens similar files generated by version 3 of the component. I also tried to open the file in Excel 2007 on the other PC; it does but immediatety crashes too when I turn macroses on.

The code is pretty simple. Probably I do something wrong; if so, please advise what I should change.
Here it is:

procedure TForm7.Button1Click(Sender: TObject);
var
vba: TVBAModuleSource;
begin
xlsRW.Clear;
xlsRW.Filename := 'c:\test.xls';
xlsRW.Sheet[0].Name := 'Test';
xlsRW.VBA.EditVBA := True;
vba := xlsRW.VBA.AddModule('Module1', vmtMacro);
vba.Source.Add('Sub DoAction()');
vba.Source.Add('Sheets(0).Cells(20, 2) = "Hello world"');
vba.Source.Add('End Sub');
with xlsRW.Sheet[0].ControlsObjects.Buttons.Add do
begin
Text := 'Action!';
Col1 := 2;
Row1 := 2;
Col2 := 4;
Row2 := 4;
MacroName := 'DoAction';
end;
xlsRW.Write;
end;

Here is an Excel crash report:

Problem signature:
Problem Event Name: APPCRASH
Application Name: EXCEL.EXE
Application Version: 11.0.5612.0
Application Timestamp: 3f39ff9d
Fault Module Name: EXCEL.EXE
Fault Module Version: 11.0.5612.0
Fault Module Timestamp: 3f39ff9d
Exception Code: c0000005
Exception Offset: 000eb7ae
OS Version: 6.0.6000.2.0.0.256.6
Locale ID: 1049

Additional information about the problem:
LCID: 1049
Brand: Office11Crash
skulcid: 1033
Post Reply