function TForm1.opendoc(filename: OleVariant): boolean;
var
      ItemIndex: OleVariant;
      ConfirmConversions, ReadOnly, AddToRecentFiles,
            PasswordDocument, PasswordTemplate, Revert,
            WritePasswordDocument, WritePasswordTemplate, Format, Encoding, Visible1: OleVariant;
begin
{Open document}
      result := true;
      ConfirmConversions := False;
      ReadOnly := False;
      AddToRecentFiles := False;
      PasswordDocument := '';
      PasswordTemplate := '';
      Revert := True;
      WritePasswordDocument := '';
      WritePasswordTemplate := '';
      Format := wdOpenFormatDocument;
      try
            WordApplication.Disconnect;
            WordApplication.Connect;
            WordDocument.ConnectTo(WordApplication.Documents.Open(FileName, ConfirmConversions, ReadOnly,
                  AddToRecentFiles, PasswordDocument, PasswordTemplate, Revert,
                  WritePasswordDocument, WritePasswordTemplate, Format, Encoding, Visible1));
            WordApplication.Options.CheckSpellingAsYouType := False;
            WordApplication.Options.CheckGrammarAsYouType := False;
            
      except
            result := false;
      end;
end;
function TForm1.replacedoc(text, rtext: string): boolean;
var
      FindText, MatchCase, MatchWholeWord, MatchWildcards, MatchSoundsLike,
            MatchAllWordForms, Forward1, Wrap, Format, ReplaceWith, Replace, MatchKashida, MatchDiacritics,
            MatchAlefHamza, MatchControl: OleVariant;
begin
      FindText := text;
      MatchCase := False;
      MatchWholeWord := True;
      MatchWildcards := False;
      MatchSoundsLike := False;
      MatchAllWordForms := False;
      Forward1 := True;
      Wrap := wdFindContinue;
      Format := False;
      ReplaceWith := rtext;
      Replace := True;
      result := WordDocument.Range.Find.Execute(FindText, MatchCase, MatchWholeWord,
            MatchWildcards, MatchSoundsLike, MatchAllWordForms, Forward1,
            Wrap, Format, ReplaceWith, Replace, MatchKashida, MatchDiacritics,
            MatchAlefHamza, MatchControl);end;procedure TForm1.closedoc;
var
      SaveChanges, OriginalFormat, RouteDocument: OleVariant;
begin
      SaveChanges := WdDoNotSaveChanges; //wdSaveChanges;
      OriginalFormat := UnAssigned;
      RouteDocument := UnAssigned;
      try
            WordApplication.Quit(SaveChanges);
            WordApplication.Disconnect;
      except
//    on E: Exception do
//    begin
//      Showmessage(E.Message);
            WordApplication.Disconnect;
//    end;
      end;
end;procedure TForm1.Button1Click(Sender: TObject);
var
      FileName1: OleVariant;
      i: integer;
begin
      ADOQUERY1.First;
      if opendoc('D:\测试程序\word打印\建设工程测量通知书.doc') = false then
      begin
            closedoc;
      end;
      filename1 := 'D:\测试程序\word打印\TEST.DOC';
      replacedoc('jsdw', ADOQUERY1.fieldbyname('dwmc').AsString);
      replacedoc('BJBH', ADOQUERY1.fieldbyname('BJBH').AsString);
      replacedoc('XMMC', ADOQUERY1.fieldbyname('XMMC').AsString);
      replacedoc('XMDZ', ADOQUERY1.fieldbyname('XMDZ').AsString);
      try
            WordDocument.SaveAs(FILENAME1);
            WORDDOCUMENT.Printout;//为什么不能打印这个文件?
      finally
            closedoc;
            application.ProcessMessages;
      end;
end;
还有问题就是怎么控制显示word打印的预览?
怎么控制用哪个打印机打印?