Formatting of document along with headers and footers removed after adding new text programatically

  Kiến thức lập trình

I have an original doc file and here I am replacing some texts using microsoft.interop.word.

After replacing the text I have to add additional text in the doc file after specific location.For this I am using the below code

int InsertIndex = DocText.IndexOf(SearchFor) + SearchFor.Length; 
DocText = DocText.Substring(0, InsertIndex) + NewlyAdded + DocText.Substring(InsertIndex);

But this method removes the complete headers and footers and formatting of the doc file.

So please help me to add text without removing the headers and footers and formatting. Is there any other way to achieve this

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT