Hello all,
I'm currently developing a tool that can copy Header and/or Footer from a reference MS Word document and paste it in multiple files. Now I'm facing problem as the header and/or footer is same for the whole document, where I want to make separate header and/or footer for each page or each section. So, I need to retrieve the MS Word Document page by page or section by section and paste the necessary header and/or footer.
Any help from anyone?
Molla Rashied HusseinPosted May 5, 2008, 1:59 AM
Hey I got a solution regarding accessing a MS Word file section by section or page by page.
First we have to create an application reference:
Microsoft.Office.Interop.Word.Application varWord = new Microsoft.Office.Interop.Word.Application();
Then by this code, we can go to next section:
varWord.Selection.GoToNext(Microsoft.Office.Interop.Word.WdGoToItem.wdGoToSection);
We can also go to next page by this:
varWord.Selection.GoToNext(Microsoft.Office.Interop.Word.WdGoToItem.wdGoToPage);
If you want to go to previous section/page, use "GoToPrevious" instead of "GoToNext".
Thanks.