VBA support
Posted: Fri Apr 26, 2013 8:47 am
Hello
Is there a macros support for Excel97? The sample code from BIFF_VBA5.pas works but Excel 2003 crashes trying to open output file.
By the way, there is an odd thing: "ReadMacros := true" is necessary to write macros. Otherwise, xlsRW.VBA is Nil.
Is there a macros support for Excel97? The sample code from BIFF_VBA5.pas works but Excel 2003 crashes trying to open output file.
Code: Select all
xlsRW.BIFF.ReadMacros := true;
xlsRW.VBA.EditVBA := True;
// Add a VBA module and a procedure.
with xlsRW.VBA.AddModule('Module1',vmtMacro) do begin
Source.Text :=
'Sub MyTestMacro()' + #13#10 +
'MsgBox "MyTestMacro executed"' + #13#10 +
'End Sub';
end;
// Add a button control.
with xlsRW.BIFF.Sheet[0].ControlsObjects.Buttons.Add do begin
Text := 'Macro test';
Col1 := 2;
Row1 := 4;
Col2 := 3;
Row2 := 5;
// The name of the macro must match the previous added macro procedure.
MacroName := 'MyTestMacro';
end;