Dzwebs.Net

撰写电脑技术杂文十余年

如何让Word文档内容折叠之VBA源代码

Admin | 2008-9-11 20:22:07 | 被阅次数 | 11280

温馨提示!

如果未能解决您的问题,请点击搜索;登陆可复制文章,点击登陆

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

  网上抄的,呵呵!


该杂文来自: Word杂文

上一篇:Word数据表格进行升序、降序排序操作图文解说

下一篇:在Word中以水平线为基准线将页面平均分为上下两栏

网站备案号:

网站备案号:滇ICP备11001339号-7

版权属性:

Copyright 2007-2021-forever Inc. all Rights Reserved.

联系方式:

Email:dzwebs@126.com QQ:83539231 访问统计