|
* 我现在不敢给 相见 写代码了,你懂的!呵呵!下面的代码并非最佳处理代码,因为处理字表混合文档,最快的还是以表格为界,分区域处理(Range),这样才快!现在的是每段都要选定,效率低下,但能完成 相见 所要求目的:
- Sub test_修改表格外文字_空段不变()
- Dim t As Table, i As Paragraph
- With ActiveDocument
- '真假回车符/手动换行符=>段落标记
- .Content.Find.Execute "[^13^11]", , , 1, , , , , , "^p", 2
- '取消表格文字环绕
- For Each t In .Tables
- With t.Range.Rows
- .WrapAroundText = False
- .Alignment = wdAlignRowCenter
- End With
- Next
- '循环遍历所有段落/仅处理表格外文字/空白行不处理(或设置为五号字)
- For Each i In .Paragraphs
- With i.Range
- '如果在表格外
- If Not .Information(12) Then
- '选定
- .Select
- '居中/两端对齐=>删除段落首尾空格(半角空格/全角空格/不间断空格/制表符)
- CommandBars.FindControl(ID:=122).Execute
- CommandBars.FindControl(ID:=123).Execute
- '空白段落(字长为1的段落)
- If Len(.Text) = 1 Then
- .Font.Size = 10.5 '五号(屏蔽/注释/删除此语句则不处理)
- Else
- '字体格式
- With .Font
- .Name = "黑体"
- .Name = "Times New Roman"
- .Size = 22
- .Bold = True
- .Color = wdColorRed '红色
- End With
- End If
- End If
- End With
- Next
- End With
- Selection.HomeKey 6 '光标移至文首
- End Sub
复制代码 |
|