死
死神十三
Unregistered / Unconfirmed
GUEST, unregistred user!
问题已经知道是哪句,但是还是不知道怎么解决
完整的代码是
procedure TForm1.Button2Click(Sender: TObject);
var i : integer;
begin
combobox1.Items.Clear;
xlapp := createoleobject('excel.application');
opendialog1.Filter := 'EXCEL工作表(*.xls)|*.xls';
if opendialog1.Execute then
begin
xlapp.workbooks.open(opendialog1.FileName);
end
else exit;
showmessage('请选择工作表');
For i:=1 to xlapp.Worksheets.Count do
ComboBox1.Items.Add(xlapp.Worksheets.Item.Name);
showmessage('aaa');
//xlapp := Unassigned;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
xlapp.worksheets[combobox1.text].activate;
xlapp.cells[1,1]:='abbbba';
xlapp.workbooks.close;
xlapp.quit;
xlapp := Unassigned;
end;
问题就出在xlapp.worksheets[combobox1.text].activate;,去处这句,没有excel进程
加上那么就关不掉excel进程
完整的代码是
procedure TForm1.Button2Click(Sender: TObject);
var i : integer;
begin
combobox1.Items.Clear;
xlapp := createoleobject('excel.application');
opendialog1.Filter := 'EXCEL工作表(*.xls)|*.xls';
if opendialog1.Execute then
begin
xlapp.workbooks.open(opendialog1.FileName);
end
else exit;
showmessage('请选择工作表');
For i:=1 to xlapp.Worksheets.Count do
ComboBox1.Items.Add(xlapp.Worksheets.Item.Name);
showmessage('aaa');
//xlapp := Unassigned;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
xlapp.worksheets[combobox1.text].activate;
xlapp.cells[1,1]:='abbbba';
xlapp.workbooks.close;
xlapp.quit;
xlapp := Unassigned;
end;
问题就出在xlapp.worksheets[combobox1.text].activate;,去处这句,没有excel进程
加上那么就关不掉excel进程