Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 抄写单词脚注_C#_Ms Word_Ms Office - Fatal编程技术网

C# 抄写单词脚注

C# 抄写单词脚注,c#,ms-word,ms-office,C#,Ms Word,Ms Office,我有两个word文档。除脚注外,两份文件都是相等的,只有一份文件包含注释。 我需要把一份文件上的笔记复制到同一位置上的另一份文件上。 我正在使用Microsoft.Office.Interop.Word.COM引用 有什么想法吗?嗯,我自己找到了一个解决办法: foreach (Microsoft.Office.Interop.Word.Footnote x in doc.Footnotes) { //MessageBox.Show(x.Range.Text); object

我有两个word文档。除脚注外,两份文件都是相等的,只有一份文件包含注释。 我需要把一份文件上的笔记复制到同一位置上的另一份文件上。 我正在使用Microsoft.Office.Interop.Word.COM引用


有什么想法吗?

嗯,我自己找到了一个解决办法:

foreach (Microsoft.Office.Interop.Word.Footnote x in doc.Footnotes)
{
    //MessageBox.Show(x.Range.Text);

    object selStart = x.Range.Start;
    object selEnd = x.Range.End;
    object missing = Type.Missing;
    object footnote = x.Range.Text;
    Range range = doc2.Range(ref selStart, ref selEnd);
    doc2.Footnotes.Add(range, ref missing, x.Range.Text);
}

我试着读word笔记,但不知道如何将它们插入到另一个文档中。阅读说明很简单:foreach Microsoft.Office.Interop.Word.Footnote x在doc.Footnotes{。。
 public static void FindFootnoteInDocument(Word.Document doc)
        {
     foreach (Microsoft.Office.Interop.Word.Footnote paragraph in doc.Footnotes)
                {
                    paragraph.Range.Select();
                    Microsoft.Office.Interop.Word.Style style1 = paragraph.Application.Selection.get_Style() as Microsoft.Office.Interop.Word.Style;
                    string styleName1;
                    if (style1 != null)
                        styleName1 = style1.NameLocal;
                    else
                        styleName1 = "Footnote Text";
                    int range = paragraph.Range.Start;
                    Word.Range ty = APIWrapper.APIUtility.GetWordRange(doc.Name, paragraph.Range.Start, paragraph.Range.End);
                    object unit = Word.WdUnits.wdWord;
                    object count = 1;
                    object extend = Word.WdMovementType.wdMove;
                    int t = paragraph.Application.Selection.Range.Move(ref unit, ref count);
                    string text = paragraph.Range.Text;
                    if (styleName1 == "Footnote Text")
                    {
                        Word.Selection currentSelection = doc.Application.Selection;
                        currentSelection.Find.ClearFormatting();
                        object style = "Footnote Text";
                        currentSelection.Find.set_Style(ref style);
                        var _with1 = currentSelection.Find;
                        _with1.Text = "";
                        _with1.Replacement.Text = "";
                        _with1.Forward = true;
                        _with1.Wrap = Word.WdFindWrap.wdFindContinue;
                        _with1.Format = true;
                        _with1.MatchCase = false;
                        _with1.MatchWholeWord = false;
                        _with1.MatchWildcards = false;
                        _with1.MatchSoundsLike = false;
                        _with1.MatchAllWordForms = false;
                        currentSelection.Cut();
                        object Count1 = 1;
                        object Unit1 = WdUnits.wdLine;
                        object Extend1 = WdMovementType.wdExtend;

                        doc.Application.Selection.MoveUp(ref Unit, ref Count, ref missing);
                        currentSelection.Find.Execute();//Execute()
                        while (currentSelection.Find.Found)
                        {
                           currentSelection.Range.Select();
                         string textvalue = currentSelection.Range.Text;
                         r2.Text = textvalue;
            MessageBox.Show("Sent lines :" + currentSelection.Text.ToString());
                          r2.set_Style(ref style);
                         break;  
                        }
                    }
                }
                break;
            }
        }