Asp.net Word自动化--将页码添加到页面顶部

Asp.net Word自动化--将页码添加到页面顶部,asp.net,.net,ms-word,Asp.net,.net,Ms Word,我正在使用Office Word Com构建Word文档,并在页眉中添加了页码 但我需要分页格式如下: 其唯一编号为: 十, 我想成为: 11月10日至11日 此外,我还想添加字体格式(粗体、fontname、fontsize) 代码如下: Sub addnumber(ByRef oWordDoc As Word.Document) oWordDoc.ActiveWindow.ActivePane.View.SeekView = Word.WdSeekView.wdSe

我正在使用Office Word Com构建Word文档,并在页眉中添加了页码 但我需要分页格式如下:

其唯一编号为: 十,

我想成为:

11月10日至11日

此外,我还想添加字体格式(粗体、fontname、fontsize) 代码如下:

   Sub addnumber(ByRef oWordDoc As Word.Document)


        oWordDoc.ActiveWindow.ActivePane.View.SeekView = Word.WdSeekView.wdSeekCurrentPageHeader
        oWordDoc.ActiveWindow.ActivePane.Selection.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter
        Dim CurrentPage As Object = Word.WdFieldType.wdFieldNumPages
        oWordDoc.ActiveWindow.Selection.Fields.Add(oWordDoc.ActiveWindow.Selection.Range, CurrentPage, Type.Missing)




    End Sub
检查以下代码:

 oWordDoc.ActiveWindow.ActivePane.View.SeekView = Word.WdSeekView.wdSeekCurrentPageHeader

            oWordDoc.ActiveWindow.ActivePane.Selection.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter


            Dim CurrentPage As Object = Word.WdFieldType.wdFieldNumPages
            Dim CurrentPage1 As Object = Word.WdFieldType.wdFieldPage
            Dim format As Object = True
            oWordDoc.ActiveWindow.Selection.Range.Bold = True
            oWordDoc.ActiveWindow.Selection.Range.Font.Name = "Arial"
            oWordDoc.ActiveWindow.Selection.Range.Font.Size = 10

            oWordDoc.ActiveWindow.Selection.Fields.Add(oWordDoc.ActiveWindow.Selection.Range, CurrentPage, Type.Missing, format)
            oWordDoc.ActiveWindow.Selection.TypeText(" from ")
            oWordDoc.ActiveWindow.Selection.Fields.Add(oWordDoc.ActiveWindow.Selection.Range, CurrentPage1, Type.Missing, format)
检查以下代码:

 oWordDoc.ActiveWindow.ActivePane.View.SeekView = Word.WdSeekView.wdSeekCurrentPageHeader

            oWordDoc.ActiveWindow.ActivePane.Selection.Paragraphs.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter


            Dim CurrentPage As Object = Word.WdFieldType.wdFieldNumPages
            Dim CurrentPage1 As Object = Word.WdFieldType.wdFieldPage
            Dim format As Object = True
            oWordDoc.ActiveWindow.Selection.Range.Bold = True
            oWordDoc.ActiveWindow.Selection.Range.Font.Name = "Arial"
            oWordDoc.ActiveWindow.Selection.Range.Font.Size = 10

            oWordDoc.ActiveWindow.Selection.Fields.Add(oWordDoc.ActiveWindow.Selection.Range, CurrentPage, Type.Missing, format)
            oWordDoc.ActiveWindow.Selection.TypeText(" from ")
            oWordDoc.ActiveWindow.Selection.Fields.Add(oWordDoc.ActiveWindow.Selection.Range, CurrentPage1, Type.Missing, format)