我的文档中有一些书签。我想向这些书签添加内容控件,但是在添加它们时遇到了麻烦,详细信息如下:
错误:
不能使用RTF控件
此外,我发现了一些书签的"bm.start"!="cc.start" "bm.end"!="cc.end"
wapp = new Word.Application();
wdoc = wapp.Documents.Open(filepath);
Word.Range r;
foreach (Word.Bookmark bm in wdoc.Bookmarks)
{
string bmName = bm.Name;
errorTag = bmName;
string bmText = bm.Range.Text;
int nStart = bm.Start;
int nEnd = bm.End;
if (nStart == nEnd)
continue;
r = wdoc.Range(nStart, nEnd);
r.Font.Size = 12;
r.Font.Name = "宋体";
r.Font.Color = Word.WdColor.wdColorBlue;
Word.ContentControl cc = wdoc.ContentControls.Add(Word.WdContentControlType.wdContentControlRichText, r);
cc.Tag = bmName;
cc.Appearance = Word.WdContentControlAppearance.wdContentControlHidden;