p; TablesOfContents.Item(1).TabLeader := wdTabLeaderDots; TablesOfContents.Format := wdIndexIndent; end; end; //创立书签 procedure TMyWord.createBookMark(BookMarkName: string); var pRange: olevariant; begin pRange := FWord.Selection.Range; with FWord.ActiveDocument.Bookmarks do begin Add(BookMarkName, pRange); DefaultSorting := wdSortByName; ShowHidden := False; end; end; //移动到标签 procedure TMyWord.GotoBookMark(BookMarkName: string); var What: olevariant; Which: olevariant; Count: olevariant; Name: olevariant; begin What := wdGoToBookmark; Name := ''BEGIN''; FWord.Selection.GoTo_(What, Which, Count, Name) end; //粘贴 procedure TMyWord.paste(); begin FWord.Selection.paste; end; //替换 procedure TMyWord.Replace(Source, Target: string); var FindText: olevariant; PWrap: olevariant; ReplaceWith: olevariant; Replace: olevariant; begin FWord.Selection.Find.ClearFormatting; FWord.Selection.Find.Replacement.ClearFormatting; FindText := Source; PWrap := wdFindContinue; ReplaceWith := Target; Replace := wdReplaceAll; with FWord.Selection.Find do begin {Text := source; Replacement.Text := Target; forward := True; Wrap := wdFindContinue; Format := False; MatchCase := False; MatchWholeWord := False; MatchByte := True; MatchWildcards := False; MatchSoundsLike := False; MatchAllWordForms := False; } Execute(FindText, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, PWrap, EmptyParam, ReplaceWith, Replace, EmptyParam, EmptyParam, EmptyParam, EmptyParam); end;