|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
楼主,下面是《全文红色/宋体/小二_前后插入书名号》三个宏:(楼主问题WAIT)
*****************************
Sub 全文红色_前后插入书名号()
Dim i As Paragraph, n As Long
For Each i In ActiveDocument.Paragraphs
i.Range.Select
'选定段落查找红色字符_前后添加书名号
Selection.HomeKey Unit:=wdLine
Do
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
If Selection.Characters.Last.Text = vbCr Then Exit Do
If Selection.Characters.Last.Font.Color = wdColorRed Then
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
If Selection.Characters.Last.Font.Color = wdColorRed Then
Do
If Selection.Characters.Last.Text = vbCr Then Exit Do
If Selection.Characters.Last.Font.Color = wdColorRed Then
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Else
Selection.MoveEnd Unit:=wdCharacter, Count:=-1
Exit Do
End If
Loop
Else
Selection.MoveEnd Unit:=wdCharacter, Count:=-1
End If
Selection.InsertBefore Text:="《"
Selection.Font.Color = wdColorRed
If Selection.Characters.Last.Text = vbCr Then Selection.MoveEnd Unit:=wdCharacter, Count:=-1
Selection.InsertAfter Text:="》"
Selection.MoveRight Unit:=wdCharacter, Count:=1
Else
Selection.MoveRight Unit:=wdCharacter, Count:=1
End If
Loop
Next
End Sub
Sub 全文宋体_前后插入书名号()
Dim i As Paragraph, n As Long
For Each i In ActiveDocument.Paragraphs
i.Range.Select
'选定段落查找宋体字符_前后添加书名号
Selection.HomeKey Unit:=wdLine
Do
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
If Selection.Characters.Last.Text = vbCr Then Exit Do
If Selection.Characters.Last.Font.Name = "宋体" Then
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
If Selection.Characters.Last.Font.Name = "宋体" Then
Do
If Selection.Characters.Last.Text = vbCr Then Exit Do
If Selection.Characters.Last.Font.Name = "宋体" Then
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Else
Selection.MoveEnd Unit:=wdCharacter, Count:=-1
Exit Do
End If
Loop
Else
Selection.MoveEnd Unit:=wdCharacter, Count:=-1
End If
Selection.InsertBefore Text:="《"
Selection.Font.Name = "宋体"
If Selection.Characters.Last.Text = vbCr Then Selection.MoveEnd Unit:=wdCharacter, Count:=-1
Selection.InsertAfter Text:="》"
Selection.MoveRight Unit:=wdCharacter, Count:=1
Else
Selection.MoveRight Unit:=wdCharacter, Count:=1
End If
Loop
Next
End Sub
Sub 全文小二_前后插入书名号()
Dim i As Paragraph, n As Long
For Each i In ActiveDocument.Paragraphs
i.Range.Select
'选定段落查找小二字符_前后添加书名号
Selection.HomeKey Unit:=wdLine
Do
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
If Selection.Characters.Last.Text = vbCr Then Exit Do
If Selection.Characters.Last.Font.Size = 18 Then
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
If Selection.Characters.Last.Font.Size = 18 Then
Do
If Selection.Characters.Last.Text = vbCr Then Exit Do
If Selection.Characters.Last.Font.Size = 18 Then
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Else
Selection.MoveEnd Unit:=wdCharacter, Count:=-1
Exit Do
End If
Loop
Else
Selection.MoveEnd Unit:=wdCharacter, Count:=-1
End If
Selection.InsertBefore Text:="《"
Selection.Font.Size = 18
If Selection.Characters.Last.Text = vbCr Then Selection.MoveEnd Unit:=wdCharacter, Count:=-1
Selection.InsertAfter Text:="》"
Selection.MoveRight Unit:=wdCharacter, Count:=1
Else
Selection.MoveRight Unit:=wdCharacter, Count:=1
End If
Loop
Next
End Sub |
|