【发布时间】:2021-01-14 15:05:11
【问题描述】:
我正在使用 Delphi 10.4 将 ContentControl 插入 MS Word 文档
使用以下 sn-p 将内容控件插入到模板上的书签中:
procedure TBF.SetPI;
var
R: WordRange;
bookmark: OleVariant;
s: string;
begin
s:= 'insert text here';
bookmark := 'textValue';
R := MF.WordDoc.Bookmarks.Item(bookmark).Range;
R.Text := s;
R.HighlightColorIndex := wdYellow;
MF.WordDoc.ContentControls.Add(wdContentControlRichText,R);
end;
这成功创建了 ContentControl,但是一旦编辑了文本,该控件就会保持不变。
Word 可以选择将 ContentControls 标记为“临时”,而 VBA 是
Selection.ParentContentControl.Temporary = True
Delphi 公开了与 R.ParentContentControl.Temporary 相同的内容,需要 WordBool 值。
尽我所能,我无法让 Delphi 接受 True 值并将其传递给 Word。
【问题讨论】:
标签: delphi ms-word delphi-10.4-sydney