如果让用户点一个按钮自动打开磁盘上的Excel文件?(50分)

  • 主题发起人 主题发起人 jerry_huang
  • 开始时间 开始时间
J

jerry_huang

Unregistered / Unconfirmed
GUEST, unregistred user!
比如说,C:/MyExcel.xls,希望用户点击btnExcel后打开,如何写这段代码呢?谢谢!
 
请引用 /demos/doc/filemanex目录的FMXUtils
使用函数 ExecuteFile
 
procedure TForm1.Button1Click(Sender: TObject);
begin
try
wordapplication1.connect;
except
messagedlg('word may not be installed', mterror, [mbok], 0);
abort;
end;
wordapplication1.visible := true;
wordapplication1.caption := 'delphi automation';
end;

procedure TForm1.Button2Click(Sender: TObject);
var
Itemindex, format,TempEmpty: olevariant;
filename, passworddocument, passwordtemplate: olevariant;
writepassworddocument, writepasswordtemplate: olevariant;
confirmconversions, readonly, revert, addtorecentfiles: olevariant;
begin
filename:='d:/1.DOC';
confirmconversions := false;
readonly := false;
addtorecentfiles := false;
revert := true;
passworddocument := '';
passwordtemplate := '';
writepassworddocument := '';
writepasswordtemplate := '';
format := wdopenformatdocument;
wordapplication1.documents.open(filename, confirmconversions,
readonly, addtorecentfiles, passworddocument, passwordtemplate,
revert, writepassworddocument, writepasswordtemplate, format,TempEmpty,TempEmpty,TempEmpty,TempEmpty,TempEmpty);
end;

你自己改一下,自己写的,可以打开Word,将它改一下可以打开Excel了
 
后退
顶部