-2

私は2つのWord文書を持っています。脚注を除いて、両方のドキュメントは同じです(1つのドキュメントにメモが含まれています)。そのメモを1つのドキュメントから同じ位置にある別のドキュメントにコピーする必要があります。Microsoft.Office.Interop.WordCOMリファレンスを使用しています。

何か案が?

4

2 に答える 2

0

さて、私は自分で解決策を見つけました:

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);
}
于 2013-02-18T11:47:29.027 に答える
0
 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;
            }
        }
于 2016-08-08T14:02:56.977 に答える