如何用vb程序给word文档加页眉页脚

如何用vb程序给word文档加页眉页脚,上下两条横线,类似下面这样
_______________________________________word1

**
**
**
——————————————–

 
第 1 楼    hot1kang1(许仙)
2006-4-18 18:07:04
得分:20   返回顶部
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
        ActiveWindow.Panes(2).Close
    End If
    If ActiveWindow.ActivePane.View.Type = wdNormalView or ActiveWindow. _
        ActivePane.View.Type = wdOutlineView Then
        ActiveWindow.ActivePane.View.Type = wdPrintView
    End If
    ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
    Selection.TypeParagraph
    ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument

你可以在word里 录制宏,然后调用宏代码..

     Dim WordApp As Word.Application
     Dim WordDoc As Word.Document
     Dim i As Integer, j As Integer
     Dim NewResult As String ‘对应的字段名
     Dim StrContent As String ‘存储勾建的结构
      
     Set WordApp = CreateObject("Word.Application")
     Set WordDoc = WordApp.Documents.Open(strWordTempLatePath)

宏 里的ActiveWindow对象也就是 WordDoc

 
第 2 楼    GoldFox(金色狐狸)
2006-4-18 18:13:11
得分:10   返回顶部
打开WORD新建一文档,开始录制宏,然后新建页眉及页脚
然后编辑宏,选择刚才录制的宏,即可看见新建页眉及页脚的VB代码
 
第 3 楼    fice_chen(火冰)
2006-4-19 13:45:49
得分:20   返回顶部
Sub aaa()
Dim doc As Document
Set doc = ActiveDocument
Selection.End = 100
Selection.Start = Selection.End
doc.Footnotes.Add Range:=Selection.Range, Text:="adjaoijdfi"
MsgBox "OK!", vbInformation
End Sub
这是页脚的一个普通例子,不知有没有用啊?

3 thoughts on “如何用vb程序给word文档加页眉页脚

  1. Pingback: CBD OIL

  2. Pingback: Bali,Indonesia

  3. Pingback: weverse

Leave a Reply