2

誰かが私を正しい方向に向けるか、c#.net で単語相互運用を使用してスタイル名で段落を見つける方法を教えてください。

4

1 に答える 1

2

次のようにループしてみてください。

using WN = Microsoft.Office.Interop.Word;
//...
        WN::Application WordApp;
        WordApp = new WN.Application();
//...        
    WN.Document WordDoc = WordApp.Documents.Open(Filename); //open document

        List<string> SelectedParagraphs = new List<string>();
        for(int i=1;i<WordDoc.Paragraphs.Count;i++) //numeration of paragraphs starts from 1
        {
                string WordP = WordDoc.Paragraphs[i].Range.Text; // get paragraph text
                string WordS = ((WN.Style)WordDoc.Paragraphs[i].get_Style()).NameLocal; //get paragraph style name
                if (WordS=="Needed style")
                {
                    SelectedParagraphs.Add(WordP);
                }
        }
于 2013-11-03T18:10:53.367 に答える