熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Delphi編程 >> 正文

Delphi+Word=數據庫+公文處理[2]

2022-06-13   來源: Delphi編程 

  讓Word打開一個指定的文件需要先放置OpenDialog然後調用WordApplicationDocumentsOpen
  var
  ItemIndex :OleVariant;
  FileName ConfirmConversions ReadOnly AddToRecentFiles
  PasswordDocument PasswordTemplate Revert
  WritePasswordDocument WritePasswordTemplate Format: OleVariant;
  begin
  if not dlgOpenExecute then
  Exit;

  {Open document}
  FileName := dlgOpenFileName;
  ConfirmConversions := False;
  ReadOnly := False;
  AddToRecentFiles := False;
  PasswordDocument := ;
  PasswordTemplate := ;
  Revert := True;
  WritePasswordDocument := ;
  WritePasswordTemplate := ;
  Format := wdOpenFormatDocument;

  WordApplicationDocumentsOpen( FileName ConfirmConversions
  ReadOnly AddToRecentFiles PasswordDocument PasswordTemplate
  Revert WritePasswordDocument WritePasswordTemplate Format );

  {Assign WordDocument component}
  ItemIndex := ;
  WordDocumentConnectTo(WordApplicationDocumentsItem(ItemIndex));

  {Turn Spell checking of because it takes a long time if enabled and   slows down Winword}
  WordApplicationOptionsCheckSpellingAsYouType := False;
  WordApplicationOptionsCheckGrammarAsYouType := False;
  end;

  讓Word替換標記字符串要使用WordDocumentRangeFindExecute這裡用Delphi替換了<#Name>
  var
  FindText MatchCase MatchWholeWord MatchWildcards MatchSoundsLike MatchAllWordForms Forward Wrap Format ReplaceWith Replace: OleVariant;
  begin
  FindText := <#Name>;
  MatchCase := False;
  MatchWholeWord := True;
  MatchWildcards := False;
  MatchSoundsLike := False;
  MatchAllWordForms := False;
  Forward := True;
  Wrap := wdFindContinue;
  Format := False;
  ReplaceWith := Delphi;
  Replace := True;

  WordDocumentRangeFindExecute( FindText MatchCase MatchWholeWord MatchWildcards MatchSoundsLike MatchAllWordForms Forward Wrap Format ReplaceWith Replace );

  end;

  上面這段代碼完成了公文管理的基本功能再把它和數據庫結合起來就可以開發一個與Lotus Notes類似的產品了

[]  []  


From:http://tw.wingwit.com/Article/program/Delphi/201311/24790.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.