Quote:
Originally Posted by macropod
Is there a reason you changed the Find strings? Your's won't do the same as mine.
|
Code:
Sub test()
Dim Rng As Range, Str1 As String, Str2 As String
With ThisDocument
With .Content
With .Find
.ClearFormatting
.MatchWildcards = True
.Text = "The Principal^13[!13]@^13" ''' the wildcards return .Find.Found = false
.Execute
End With
If .Find.Found Then
Set Rng = .Duplicate.Paragraphs.Last '''.Range
With Rng
.End = .End - 1 ''' should be -2 (-1 the comma still exists)
Str1 = Trim(.Text)
End With
End If
With .Find
.Text = "RE: [!13]@^13" ''' the wildcards return .Find.Found = false
.Execute
End With
If .Find.Found Then
Set Rng = .Duplicate.Paragraphs.Last '''.Range
With Rng
.End = .End - 1
.Start = .Start + 4
Str2 = Trim(.Text)
End With
''' End If
''' missed in the original codes
End If
End With
.SaveAs2 FileName:=.Path & "\" & Str1 & " " & Str2, FileFormat:=wdFormatDocumentDefault
End With
End Sub
It cannot "FIND" any strings.