使用Microsoft.Office.Interop.Word时强制执行页码编号

时间:2012-09-12 15:33:38

标签: vb.net interop ms-word page-numbering

我有以下VB.Net代码来创建Microsoft Word文档。我该如何强制进行页码编号?

Imports Word = Microsoft.Office.Interop.Word

Dim wordApp As Word._Application = New  _
Word.ApplicationClass()

Dim wordDoc As Word._Document = _
    wordApp.Documents.Add()

Dim para As Word.Paragraph = wordDoc.Paragraphs.Add()
para.Range.Text = "First Page Content."
para.Range.InsertParagraphAfter()

para.Range.InsertBreak()

para.Range.Text = "Second Page Content."
para.Range.InsertParagraphAfter()

1 个答案:

答案 0 :(得分:1)

你可以尝试:

 'wdAlignPageNumberCenter=1
 wordDoc.Sections(1).Footers(1).PageNumbers.Add (1)