paragraph levels are part of an enum. All you have to do is keep track of what paragraph level you are at and then grab sub level items.
static void Main(string[] args)
{
Application wrd = new Application();
Document d;
Documents docs = wrd.Documents;
object readOnly = true;
object fileName = @"C:\Users\v-chrha\Desktop\text doc.docx";
object missing = Missing.Value;
d = docs.Open(ref fileName, ref missing, ref readOnly, ref missing, ref missing
, ref missing, ref missing, ref missing, ref missing, ref missing
, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
int previousLevel = 0;
int currentLevel = 0;
foreach (Paragraph p in d.Paragraphs)
{
Console.WriteLine("Paragraph: {0}\nLevel: {1}", p.Range.Text, p.p.OutlineLevel.ToString());
switch (p.OutlineLevel)
{
case WdOutlineLevel.wdOutlineLevel1:
currentLevel = 1;
break;
case WdOutlineLevel.wdOutlineLevel2:
currentLevel = 2;
break;
case WdOutlineLevel.wdOutlineLevel3:
currentLevel = 3;
break;
case WdOutlineLevel.wdOutlineLevel4:
currentLevel = 4;
break;
case WdOutlineLevel.wdOutlineLevel5:
currentLevel = 5;
break;
case WdOutlineLevel.wdOutlineLevel6:
currentLevel = 6;
break;
case WdOutlineLevel.wdOutlineLevel7:
currentLevel = 7;
break;
case WdOutlineLevel.wdOutlineLevel8:
currentLevel = 8;
break;
case WdOutlineLevel.wdOutlineLevel9:
currentLevel = 9;
break;
case WdOutlineLevel.wdOutlineLevelBodyText:
currentLevel = 10;
break;
}
if (currentLevel > previousLevel)
Console.WriteLine("with previous");
else
Console.WriteLine("not with previous");
previousLevel = currentLevel;
}
Console.ReadLine();
docs = null;
d.Close(ref missing, ref missing, ref missing);
d = null;
wrd.Quit(ref missing, ref missing, ref missing);
wrd = null;
}
}