Word automation
-
This is more Word related than COM related, so I hope you don't mind me asking... I am using automation of MS Word to build a Word document, and would like to add footers which contain the page number, in the format [some text] [page number] [some text]. It seems to be that you can set the text of the header and footer using
HeaderFooter::GetRange()
and thenRange::SetText(),
and you can add a page number to the footer usingHeaderFooter::GetPageNumbers()
and thenPageNumbers::Add()
, but you can't marry up the text and page number. Any ideas on how I can tackle this. Alternatively, does anyone know of any good books that cover word automation to this sort of depth? Thanks in advance! -
This is more Word related than COM related, so I hope you don't mind me asking... I am using automation of MS Word to build a Word document, and would like to add footers which contain the page number, in the format [some text] [page number] [some text]. It seems to be that you can set the text of the header and footer using
HeaderFooter::GetRange()
and thenRange::SetText(),
and you can add a page number to the footer usingHeaderFooter::GetPageNumbers()
and thenPageNumbers::Add()
, but you can't marry up the text and page number. Any ideas on how I can tackle this. Alternatively, does anyone know of any good books that cover word automation to this sort of depth? Thanks in advance!Have actually found the solution now (not ten minutes after asking :rolleyes: ), but thought I would post the solution as opposed to deleting the thread, in case anyone else had the same problem :) Instead of adding to the PageNumbers collection, all you need to do is add a field of type wdFieldPage to the header / footer range. Simple really :)