C# 如何使用C在Microsoft Word中查找段落中的脚注位置#
目前,我使用C# 如何使用C在Microsoft Word中查找段落中的脚注位置#,c#,ms-word,ms-office,footnotes,paragraphs,C#,Ms Word,Ms Office,Footnotes,Paragraphs,目前,我使用 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.Fo
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;
}
}
foreach(文件段落中的Microsoft.Office.Interop.Word.段落段落段落)
{
Microsoft.Office.Interop.Word.Range=para.Range.Duplicate;
字符串x=“”;
对于(int i=1;i我认为最好的选择是使用。查找范围对象的属性。您需要搜索表示脚注标记(在范围内)的^f
首先,我向您展示VBA中的代码(我更了解哪种语言):
我认为在C#中,它将如下所示(或类似,未经测试):
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
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));