Find Heading and Sub-heading in Word Document


Currently, I am working with word automation. I need to format the whole document according to specific requirements like making the text bold, change font size etc., The formatting needs to be done depending on the type i.e Heading1, Heading2, Body(paragraph).

Ideally, it should be like following images. For Main topics, it should be Heading1 and for sub-topics, it should be Heading2 and so on.

Some times, the Headings are not given under Heading1 style. Because of that Table of contents are not updated correctly.

Is there any way to segregate Headings and Sub-headings from a plain document ? Please help me in finding solution.