0

目前我使用检索段落中的脚注文本

     foreach (Microsoft.Office.Interop.Word.Paragraph para in doc.Paragraphs)
        {
            Microsoft.Office.Interop.Word.Range range = para.Range.Duplicate;

            string x = "";
            for (int i = 1; i <= para.Range.Footnotes.Count; i++)
            {
                x = para.Range.Footnotes[i].Range.Text;
             }
        }

但是我想在段落中的脚注脚本旁边附加文本“x”以进行处理。我想知道是否可以使用位置导航或使用脚注标记的任何分隔符拆分段落,以便我可以重新创建附加正文和脚注文本的文本。

4

1 回答 1

0

在我看来,最好的选择是使用.Find property. Range object您将需要搜索^f代表脚注标记(在范围内)。

首先,我向您展示 VBA 中的代码(我更了解哪种语言):

para.Range.Select
Selection.Find.Execute "^f"
//'the code below will insert footnote text after your footnote mark
Selection.InsertAfter " " & Selection.Footnotes(1).Range.Text

我认为在 C# 中它看起来如下(或类似,未经测试):

para.Range.Select;
Selection.Find.Execute("^f", ref Type.Missing, ref Type.Missing, ref Type.Missing, ref Type.Missing,
                             ref Type.Missing, ref Type.Missing, ref Type.Missing, ref Type.Missing,
                             ref Type.Missing, ref Type.Missing, ref Type.Missing, ref Type.Missing,
                             ref Type.Missing, ref Type.Missing);

Selection.InsertAfter(string.Format(" {0}", Selection.Footnotes[1].Range.Text));
于 2013-10-20T21:40:57.937 回答