Dzwebs.Net

撰写电脑技术杂文十余年

word vba 选中段落

Admin | 2016-5-13 5:54:54 | 被阅次数 | 22602

温馨提示!

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

  使用下面的代码,可以选中WORD的段落。

  一、选中某些字或段落

  ActiveDocument.Words(3).Select
  ActiveDocument.Paragraphs(3).Range.Select

  二、选中某个范围的内容

  以下代码可选定两个【例子】之间的内容   
            
  Selection.Find.ClearFormatting   
          With Selection.Find   
                  .Text   =   "【例子】"   
                  .Forward   =   True   
                  .Wrap   =   wdFindContinue   
          End With   
  Selection.Find.Execute   
  range1   =   Selection.End   
  Selection.Find.Execute   
  range2   =   Selection.Start   
  ActiveDocument.Range(range1,range2).Select

  三、选中红色文字所在的段落

  Dim myRange As Range
  Set myRange = ActiveDocument.Content
  '定义myRange为主文档文章
  With myRange.Find
  '在里面主文档里面查找东西
     .Format = True
     .Font.Color = wdColorBlue '字体为蓝色
     If .Execute = True Then myRange.Paragraphs(1).Range.Select
     '运行指定的查找操作,如果查找成功,则选取
  End With


该杂文来自: Word杂文

上一篇:word vba 第X页 共Y页

下一篇:word vba 字号的设置与判断

网站备案号:

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

版权属性:

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

联系方式:

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