title: Add page number to a Word document using Python
body: <p>Is there a way to add page numbers to the lower right corner of a Word document using Python win32com? I am able to add headers and footers, but I can't find a way to add page numbers in the format PageNumber of TotalPages (for example: 1 of 5)</p>
  
  <p>Below is the code to add centered headers and footers to a page</p>
  
  <pre><code>from win32com.client import Dispatch as MakeDoc
  filename = name + '.doc'
  WordDoc = MakeDoc("Word.Application")
  WordDoc = WordDoc.Documents.Add()
  WordDoc.Sections(1).Headers(1).Range.Text = name
  WordDoc.Sections(1).Headers(1).Range.ParagraphFormat.Alignment = 1
  WordDoc.Sections(1).Footers(1).Range.Text = filename
  WordDoc.Sections(1).Footers(1).Range.ParagraphFormat.Alignment = 1
  </code></pre>
  
  <p>Thanks</p>