Hi, I am adding header and footer with Interop.Word and creating a Word document. I am adding an image and and text in the header and footer. When I run the application for the first time, the header and footer gets inserted. But when I run the application the next time, the header and footer keeps getting added and the whole document gets filled up only with header and footer. Is there a way to check, so if a header is inserted, it does not get inserted again, or to check check the number of images in the header and footer. I am doing something as below to add header and footer.
HeaderFooter header; header = aDoc.Sections[1].Headers[Microsoft.Office.Interop.Word.WdHeaderFooterIndex.wdHeaderFooterPrimary]; Range headerRange; headerRange = header.Range; Paragraph headerImagePara = headerRange.Paragraphs.Add(ref missing); int headerImageCount = headerImagePara.Range.InlineShapes.Count; headerImagePara.Range.InlineShapes.AddPicture(imageurl, ref missing, ref missing, ref missing); headerImagePara.Range.ParagraphFormat.Alignment=WdParagraphAlignment.wdAlignParagraphCenter; Paragraph headerTextPara = headerRange.Paragraphs.Add(ref missing); headerTextPara.Range.Text = "Header Text"; headerTextPara.Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter;