|
* 经 ming0018 老师提示,不断尝试,终于达到目的,可以一键选定表外文字;但前期预处理工作需要自己搞,比如:替换回车符/手动换行符,表格取消文字环绕,删除空行空格等。
* 方法一3次测试时间为:.39/.34/.43秒;方法二3次测试时间为:.14/.23/.23秒。选后执行《正文样式》宏。
- Sub 选定表外文字_方法一()
- Dim i As Paragraph
- With ActiveDocument
- For Each i In .Paragraphs
- If Not i.Range.Information(12) Then i.Range.Editors.Add -1
- Next
- .SelectAllEditableRanges -1
- .DeleteAllEditableRanges -1
- End With
- End Sub
- Sub 选定表外文字_方法二()
- Dim j&, k&
- With ActiveDocument
- If .Tables.Count = 0 Then
- .Select
- Else
- If Not .Paragraphs(1).Range.Information(12) Then .Range(Start:=0, End:=.Tables(1).Range.Start).Editors.Add -1
- k = .Tables.Count
- For j = 1 To k
- If j = k Then Exit For
- .Range(Start:=.Tables(j).Range.End, End:=.Tables(j + 1).Range.Start).Editors.Add -1
- Next j
- .Range(Start:=.Tables(k).Range.End, End:=.Content.End).Editors.Add -1
- .SelectAllEditableRanges -1
- .DeleteAllEditableRanges -1
- End If
- End With
- End Sub
- Sub 正文样式()
- With Selection
- .ClearFormatting
- CommandBars.FindControl(ID:=122).Execute
- CommandBars.FindControl(ID:=123).Execute
- With .Font
- .Name = "仿宋_GB2312"
- .Size = 16
- .Color = wdColorBlue
- .Kerning = 0
- .DisableCharacterSpaceGrid = True
- End With
- With .ParagraphFormat
- .LineSpacing = LinesToPoints(1.5)
- .CharacterUnitFirstLineIndent = 2
- .AutoAdjustRightIndent = False
- .DisableLineHeightGrid = True
- End With
- End With
- End Sub
复制代码 |
|