Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. COM
  4. Word automation

Word automation

Scheduled Pinned Locked Moved COM
comtestingtoolsquestion
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Martyn Pearson
    wrote on last edited by
    #1

    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 then Range::SetText(), and you can add a page number to the footer using HeaderFooter::GetPageNumbers() and then PageNumbers::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!

    M 1 Reply Last reply
    0
    • M Martyn Pearson

      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 then Range::SetText(), and you can add a page number to the footer using HeaderFooter::GetPageNumbers() and then PageNumbers::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!

      M Offline
      M Offline
      Martyn Pearson
      wrote on last edited by
      #2

      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 :)

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups