to sophia531(雨桐)
在表中添加一字段来标记word文件(比如数字编号)即可,定位时用
adoquery1.close;
adoquery1.sql.clear;
adoquery1.sql.add('select * from <表名> where <字段1>='+<编号>);
adoquery1.sql.open;
打开word文件。
procedure TfjfsglForm.SpeedButton4Click(Sender: TObject);
var
MSWord: Variant;
str:string;
begin
if trim(DataModule1.adoquery27.fieldbyname('fjmc').asstring)<>'' then
begin
str:=trim(DataModule1.ADOQuery27.fieldbyname('fjmc').AsString);
MSWord:= CreateOLEObject('Word.Application');//
MSWord.Documents.Open('d:\Program Files\Common Files\Sfa\'+str, True);//
MSWord.Visible:=1;//
str:='';
MSWord.ActiveDocument.Range(0, 0);//
MSWord.ActiveDocument.Range.InsertAfter(str);//?úWord?D???ó×?·?'Title'
MSWord.ActiveDocument.Range.InsertParagraphAfter;
end
else
showmessage('');
end;