The following code works great with Excel 95 but generates a "Member not
found." error using Excel 97. Anybody know what I'm doing wrong?
{**** Begin code ****}
unit MainForm;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs,
ComObj, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
{*** Public member declarations ***}
Excel : Variant;
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
try
Excel := CreateOleObject('Excel.Application');
Excel.WorkBooks.Add;
Excel.Visible := True;
Excel.WindowState := -4140;
except
MessageDlg('Excel could not be started.', mtError, [mbOK], 0);
end;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
try
Excel.Quit;
except
MessageDlg('Excel could not be terminated.', mtError, [mbOK], 0);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Excel.Range('A1:A1');
Excel.Selection.Value := 'Hello world!';
end;
end.
{**** End code ***}
Secondly, I've seen lots of discussion in this group which seems to
indicate that using imported type libraries is much faster that using
variants. If I import the type library for Excel8 (Excel97?) that I see
in the Import Type Library dialog in Delphi 4, what happens if my app is
installed on a machine where only Excel7 is availble? - - TIA, Del G.