Relative Content

Tag Archive for c#ms-wordvstooffice-interopcompatibility

HeaderFooter enumeration fails in VSTO application when processing Compatibility Mode docs

I have created a C# MS Word VSTO add-in in Visual Studio 2022 that loops through the footers in documents and injects a text box and field code into the footers of different sections. This code works well with .docx documents. However, with .doc documents in Compatibility Mode, WdHeaderFooterIndex.wdHeaderFooterFirstPage is mistaken for Word.WdHeaderFooterIndex.wdHeaderFooterPrimary. So the program inserts the text box and field code into the primary footer when the code asks for the First Page Footer. This results in no content inserted into the First Page Footer and duplicates inserted into the Primary Footer.