|
楼主,我也试着编了一个《文稿比较》的小宏,但测试后觉得有些不甚满意,但没办法,有热情,有干劲,就是水平低,请试用(不行就删除):
- Sub test文稿比较()
- If MsgBox("请注意:修改稿文件名必须是《修改稿》三个字!原稿文件名不必改。" & vbCr & _
- "请打开原稿和修改稿,然后必须将光标放在原稿中才能应用此宏,否则出错!-->工具/宏/宏/test文稿比较" & vbCr & vbCr & _
- "是否继续? (处理需要时间,请耐心等待一会儿!)", vbYesNo + vbCritical) = vbNo Then End
- Dim y$, a As Document, b As Document, i&, j&, k&, x&, m&, n&, u&, v&
- y = ActiveDocument.Name
- Set a = Documents(y)
- Set b = Documents("修改稿.doc")
- With b
- With .Content.Find
- .Execute "^13", , , 0, , , , , , "^p", 2
- .Execute "^11", , , 0, , , , , , "^p", 2
- .Parent.ListFormat.ConvertNumbersToText
- End With
- .Select
- CommandBars.FindControl(ID:=122).Execute
- CommandBars.FindControl(ID:=123).Execute
- With Selection.Font
- .Size = 16
- .Color = wdColorAutomatic
- End With
- End With
- With a
- With .Content.Find
- .Execute "^13", , , 0, , , , , , "^p", 2
- .Execute "^11", , , 0, , , , , , "^p", 2
- .Parent.ListFormat.ConvertNumbersToText
- End With
- .Select
- CommandBars.FindControl(ID:=122).Execute
- CommandBars.FindControl(ID:=123).Execute
- With Selection.Font
- .Size = 16
- .Color = wdColorAutomatic
- End With
- j = .Paragraphs.Count
- k = b.Paragraphs.Count
- If j > k Then x = k Else x = j
- For i = 1 To x
- u = Len(.Paragraphs(i).Range)
- v = Len(b.Paragraphs(i).Range)
- Do
- m = m + 1
- n = n + 1
- If m > u Then Exit Do
- If n > v Then Exit Do
- If .Paragraphs(i).Range.Characters(m).Text = b.Paragraphs(i).Range.Characters(n).Text Then
- .Paragraphs(i).Range.Characters(m).Font.Color = wdColorBlue
- b.Paragraphs(i).Range.Characters(n).Font.Color = wdColorBlue
- Else
- If u > v Then
- .Paragraphs(i).Range.Characters(m).Font.Color = wdColorRed
- n = n - 1
- ElseIf u < v Then
- b.Paragraphs(i).Range.Characters(n).Font.Color = wdColorRed
- m = m - 1
- Else
- .Paragraphs(i).Range.Characters(m).Font.Color = wdColorRed
- b.Paragraphs(i).Range.Characters(n).Font.Color = wdColorRed
- End If
- End If
- Loop
- m = 0
- n = 0
- Next i
- End With
- MsgBox "处理完毕!!!!!!!!!!!!", 0 + 48
- Selection.HomeKey unit:=wdStory
- Windows.CompareSideBySideWith "修改稿"
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|