Hi All,
I have a lenghty word document, content of which is organized under headings and sub headings. I want to edit the document so as to keep the entire heading (and the content) depending on some logic and remove the ones which i dont want to keep.
The powershell logic is able to determine the determine the heading i want to keep.
However, I am not able to delete the content in an efficient way. What i am currently doing is --
1. Iterating through the paragraphs of the word doc.
2. If the Style is ChapterHeading and the Text matches my list, I set a flag. I keep the stuff when the flag is set. I unset the flat when Style is ChapterHeading and the Text matches doesnt not match my list. I delete everything when the flag is unset.
The problem is --
My document is lengthy and processing takes long time to delete it paragraph wise.
Alternatively, i want to achieve deletion of the entire heading stuff like the way we do it from NavigationPane of word. I cant attach a image here. But if you select a heading from the navigation pane, you can right click and delete all content under it
in a single action
The below image shows what i want to do in my powershell code.. Any pointers on how I can do it?
-Utkarsh