打印本文 打印本文 关闭窗口 关闭窗口
如何让Word文档内容折叠之VBA源代码
作者:武汉SEO闵涛  文章来源:敏韬网  点击数2028  更新时间:2009/6/9 2:13:28  文章录入:mintao  责任编辑:mintao

Option Explicit
Sub Example1()
    Dim MyRange As Range
    With Selection
        ActiveDocument.AttachedTemplate.AutoTextEntries("展开").Insert .Range
        .Paragraphs(1).Next.Range.Font.Hidden = False
    End With
End Sub
'----------------------
Sub Example2()
    Dim MyRange As Range
    With Selection
        ActiveDocument.AttachedTemplate.AutoTextEntries("折叠").Insert .Range
        Set MyRange = ThisDocument.Range(.Paragraphs(1).Next(1).Range.Start, .Paragraphs(1).Next(2).Range.End)
        MyRange.Font.Hidden = True
    End With
End Sub
'----------------------

Private Sub Document_Close()
  Options.ButtonFieldClicks = 2
End Sub
'----------------------

Private Sub Document_New()
  Application.OrganizerCopy
End Sub
'----------------------

Private Sub Document_Open()
    With ActiveDocument.ActiveWindow
        .View.ShowAll = False
        .View.ShowHiddenText = False
    End With
    Options.ButtonFieldClicks = 1
End Sub

  网上抄的,呵呵!

打印本文 打印本文 关闭窗口 关闭窗口