|
uses ActiveX;
procedure TForm1.Button1Click (Sender: TObject);
begin
ExcelApplication1.Connect;
ExcelApplication1.Workbooks.Add (EmptyParam, 0);
ExcelApplication1.Visible [0]: = True;
(ExcelApplication1.Worksheets.Item [1] as _Worksheet) .Range ['E1', 'E5']. Select;
end;
procedure TForm1.Button2Click (Sender: TObject);
var
Enum: IEnumVariant;
Selection: OleVariant;
Application: OleVariant;
Count: Integer;
rgVar: OleVariant;
vFetched: Longword;
begin
Application: = ExcelApplication1.Application;
Selection: = Application.Selection;
Enum: = IUnknown (Selection._NewEnum) as IEnumVariant;
Count: = 0;
while Enum.Next (1, rgVar, vFetched) = S_OK do Inc (Count);
ShowMessage (IntToStr (Count));
end; |
|