SpecialCells 为何说没定义? ( 积分: 100 )

  • 主题发起人 主题发起人 newcountry
  • 开始时间 开始时间
N

newcountry

Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,ComObj;

type
TForm1 = class(TForm)
Button1: TButton;
Edit1 TEdit;
Edit2: TEdit;

procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var ExcelApp: Variant;
lastRow,lastCol :integer;
begin
ExcelApp := CreateOleObject( 'Excel.Application' );
ExcelApp.Visible := True;
ExcelApp.WorkBooks.Open('c:/EXCEL'); ExcelApp.WorkBooks.ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell,EmptyParam).Activate;
lastRow := ExcelApp.ActiveCell.Row;
lastCol := ExcelApp.ActiveCell.Column;
edit1.Text:=inttostr(lastRow);
edit2.Text:=inttostr(lastCol);
ExcelApp.WorkBooks.Close;
ExcelApp.Quit;

end;

end.
显示
ExcelApp.WorkBooks.ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell,EmptyParam).Activate;函数错误为什么阿?
 
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,ComObj;

type
TForm1 = class(TForm)
Button1: TButton;
Edit1 TEdit;
Edit2: TEdit;

procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var ExcelApp: Variant;
lastRow,lastCol :integer;
begin
ExcelApp := CreateOleObject( 'Excel.Application' );
ExcelApp.Visible := True;
ExcelApp.WorkBooks.Open('c:/EXCEL'); ExcelApp.WorkBooks.ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell,EmptyParam).Activate;
lastRow := ExcelApp.ActiveCell.Row;
lastCol := ExcelApp.ActiveCell.Column;
edit1.Text:=inttostr(lastRow);
edit2.Text:=inttostr(lastCol);
ExcelApp.WorkBooks.Close;
ExcelApp.Quit;

end;

end.
显示
ExcelApp.WorkBooks.ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell,EmptyParam).Activate;函数错误为什么阿?
 
Workbooks下面没有ActiveSheet属性。
把ExcelApp.WorkBooks.ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell,EmptyParam).Activate;这行改为
ExcelApp.WorkBooks[1].ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell,EmptyParam).Activate;
或者改为
ExcelApp.ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell,EmptyParam).Activate;
就可以了,
 
我回家试试看
 
Sound wav sound.wav 的txt文件改成.rc后把 sound.wav文件和sound.rc 文件放到bin目录下后运行 brcc32.exe sound.rc 为何不能形成Sound.rec?
正确的方法是什么啊?
 
接受答案了.
 
后退
顶部