to:mo
下面这个函数我以前贴过,可以用的。
你肯定偷懒了,没有搜索过。:)
procedure openwordfile(Myword: TWordApplication; Myfile: string;IsVisible:Boolean); //打开Word文档函数。
//Myword:文档工程名称;Myfile:word文件名;IsVisible来控制是否显示。
var
FileName, ConfirmConversions, ReadOnly, AddToRecentFiles,
PasswordDocument, PasswordTemplate, Revert,WritePasswordDocument,
WritePasswordTemplate, Format,MatchCase, MatchWholeWord, find1, rep1,
MatchWildcards, MatchSoundsLike, MatchAllWordForms, Forward,
Wrap, Replace: OleVariant;
{以上的变量都是TDocument.open函数所必需的,都是系统默认的,详情请参看Word的Help}
{可能会碰到错误的提示,一种情况是Uses一下Office97就可以了。}
begin
Myword.Connect;
Myword.Visible :=false;
FileName := MyFile; //打开的文件名称。
confirmConversions := False;
ReadOnly := False;
AddToRecentFiles := False;
PasswordDocument := '';
PasswordTemplate := '';
Revert := True;
WritePasswordDocument := '';
WritePasswordTemplate := '';
Format := wdOpenFormatDocument;
myWord.Documents.Open(FileName, ConfirmConversions,
readOnly, AddToRecentFiles, PasswordDocument, PasswordTemplate,
Revert, WritePasswordDocument, WritePasswordTemplate, Format);
Myword.Visible :=True;
Myword.Disconnect;
end;
//打开Word文档函数(结束)
再给你贴一个打开Excel的源程序,再不能提示了,再提示我就替你做出来了。散分吧!
var
i,TempInt:integer;
aa,bb,cc:string;
begin
ExcelApplication1.FindFile;
Try
ExcelApplication1.Connect;
Except
MessageDlg('Excel 没有安装,请安装后运行。', mtError, [mbOk], 0);
Abort;
End;
ProgressBar1.Visible:=True;
// ExcelWorkbook1.ConnectTo(ExcelApplication1.Workbooks[ExcelApplication1.Workbooks.count]);
// ExcelWorksheet1.ConnectTo(ExcelWorkbook1.Worksheets[1] as _Worksheet);
ExcelWorkbook1.ConnectTo(ExcelApplication1.Workbooks[1]);
ExcelWorksheet1.ConnectTo(ExcelWorkbook1.Worksheets[1] as _Worksheet);
TempInt:=round(FloatEdit1.Value);
ProgressBar1.Max:=TempInt;
ProgressBar1.StepIt;
for i:=1 to TempInt do begin
aa:=ExcelWorksheet1.Cells.item[i,1];
bb:=ExcelWorksheet1.Cells.item[i,2];
cc:=aa+bb;
ExcelWorksheet1.Cells.item[i,3]:=cc;
Application.ProcessMessages;
ProGressBar1.StepBy(1);
end;
ProgressBar1.Visible:=false;
ExcelWorkbook1.Disconnect;
ExcelWorksheet1.Disconnect;
ExcelApplication1.Disconnect;
ExcelApplication1.Visible[1]:=True;
// ExcelApplication1.Quit;