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文档函数(结束)