|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
本帖最后由 413191246se 于 2020-6-14 13:10 编辑
- Sub test()
- Dim doc As Document, newdoc As Document, i As Paragraph, j&, k&, v$, s$, t$, m$, n$, p&, q$
- Set doc = ActiveDocument
- Set newdoc = Documents.Add
- With doc
- .Activate
- With .Content
- .InsertAfter Text:=vbCr & "99、自检自查单位:"
- With .Find
- .Execute " ", , , 1, , , , , , " ", 2
- .Execute "^t", , , 1, , , , , , " ", 2
- .Execute "^s", , , 1, , , , , , " ", 2
- End With
- End With
- End With
- For p = 1 To 2
- If p = 1 Then
- q = "大型"
- ElseIf p = 2 Then
- q = "中小型"
- End If
- For k = 1 To 3
- If k = 1 Then
- v = "安全生产方面"
- ElseIf k = 2 Then
- v = "压力(消防)器材管理方面"
- ElseIf k = 3 Then
- v = "车辆管理方面"
- End If
- n = ""
- newdoc.Content.InsertAfter Text:="█ " & q & "企业 - " & v & ":" & vbCr
- For Each i In doc.Paragraphs
- With i.Range
- If .Text Like "*自检自查单位*" & q & "企业*" Then
- .Characters(InStr(.Text, ":")).Select
- With Selection
- .MoveEndUntil cset:=" "
- .MoveStart
- s = .Text
- End With
- .Select
- With Selection
- Do
- .MoveEnd
- Loop Until .Text Like "*自检自查单位"
- .MoveEnd 4, -2
- If .Text Like "*" & v & "*" Then
- .Paragraphs(1).Range.Select
- Do
- .MoveEnd
- Loop Until .Text Like "*" & v
- .Paragraphs.Last.Range.Select
- Else
- GoTo sk
- End If
- .Characters(InStr(.Text, "个") - 1).Select
- j = .Text
- If .Previous Like "[0-9]" Then .MoveStart 1, -1
- .Paragraphs(1).Range.Select
- .MoveEnd 4, j
- .MoveStart 4, 1
- t = "★ " & s & vbCr & .Text & vbCr
- n = n & t
- End With
- End If
- End With
- sk:
- Next
- newdoc.Content.InsertAfter Text:=vbCr & n
- Next k
- Next p
- doc.Close SaveChanges:=wdDoNotSaveChanges
- '''
- With ActiveDocument
- .ConvertNumbersToText
- With .Content.Font
- .NameFarEast = "宋体"
- .NameAscii = "Times New Roman"
- .Size = 10.5
- .ColorIndex = wdBlue
- End With
- For Each i In .Paragraphs
- With i.Range
- If .Text Like "█*" Then
- With .Font
- .NameFarEast = "华文中宋"
- .Size = 16
- .Bold = True
- .ColorIndex = wdRed
- End With
- ElseIf .Text Like "★*" Then
- With .Font
- .NameFarEast = "黑体"
- .Bold = True
- .ColorIndex = wdPink
- End With
- End If
- End With
- Next
- With .Content.Find
- .Execute "([、..)])([ ^s^t]{1,})", , , 1, , , , , , "\1", 2
- .Execute "(^13)([0-9]{1,}.)", , , 1, , , , , , "\1", 2
- End With
- For Each i In .Paragraphs
- With i.Range
- If Not (.Text Like "█*" Or .Text Like "★*" Or .Text = vbCr) Then .InsertBefore Text:="☆ "
- End With
- Next
- ' .Content.Font.ColorIndex = wdAuto '自动色(如果不想要彩色文档,只须删除本语句前的小撇儿'即可)
- End With
- MsgBox "处理完毕!文档尚未保存!", 0 + 48
- End Sub
复制代码
|
评分
-
1
查看全部评分
-
|