-
How about this - it does presume the numbering is the same (1.1 then 1.2 etc) in each doc
Cheers
Dave
[vba]
Option Explicit
Sub Greeks()
Dim Doc1 As Document, Doc2 As Document
Dim RegEx As Object
Dim RegO1 As Object, RegO2 As Object, i As Long
Set Doc1 = Documents("FirstDocument")
Set Doc2 = Documents("SecondDocument")
Set RegEx = CreateObject("vbscript.regexp")
RegEx.Global = True
RegEx.Pattern = "(GRK\s{1}Mt\s{1})([0-9]{1,3}:[0-9]{1,3})(.*?\r)"
Set RegO1 = RegEx.Execute(Doc1.Content.Text)
Set RegO2 = RegEx.Execute(Doc2.Content.Text)
'This code would need modding if the ordering system was different between docs
Application.ScreenUpdating = False
For i = 1 To RegO1.Count
If RegO1(i - 1).submatches(1) = RegO2(i - 1).submatches(1) Then
With Doc1.Content.Find
.Text = RegO1(i - 1)
.Replacement.Text = RegO2(i - 1)
.Execute Replace:=wdReplaceOne
End With
End If
Next
Application.ScreenUpdating = True
End Sub
[/vba]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules