以下的副程式的功用為: 在 WORD 中設定書籤. 其工作方式乃是透過 Type Library, 而不是 Variant 物件. ----------------------------------------------------------- function TWordObj.setBookmark(bkmrkName: widestring; text: wideString):boolean; var i: integer; bkmark: word_TLB.Bookmark; temp: oleVariant; begin for i:= 1 to fmydoc.Bookmarks.Count do begin temp := oleVariant(i); bkmark := fmydoc.bookmarks.Item(temp); if bkmark.Name = bkmrkname then begin bkmark.Range.Set_Text(text); exit; end; end; end; ------------------------------------------------------------