|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub 多行缩一行()
- '功能:单元格文字多行缩放为一行!
- '注意:光标在表格外,处理所有表格!光标在表格内,处理光标所在表格!
- With ActiveDocument.Content.Find
- .Execute FindText:="^l", replacewith:="", Replace:=wdReplaceAll
- .Execute FindText:="^13", replacewith:="", Replace:=wdReplaceAll
- End With
- On Error Resume Next
- Dim t As Table, c As Cell, n As Long
- If Selection.Information(wdWithInTable) = True Then Selection.Tables(1).Select: n = 1
- For Each t In ActiveDocument.Tables
- If n = 1 Then Set t = Selection.Tables(1) Else t.Select
- For Each c In t.Range.Cells
- Do
- c.Select: Selection.HomeKey Unit:=wdLine: Selection.EndKey Unit:=wdLine
- If Asc(Selection) <> 13 Then
- c.Select
- Selection.Cells(1).Range.Font.Color = wdColorRed
- Selection.Font.Scaling = Selection.Font.Scaling - 5
- Else
- Exit Do
- End If
- Loop
- Next
- If n = 1 Then Exit For
- Next
- MsgBox "处理完毕!", vbOKOnly + vbExclamation, "单元格文字多行缩放为一行"
- End Sub
复制代码 |
|