View Single Post
 
Old 04-17-2012, 06:32 AM
tinfanide tinfanide is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: Aug 2011
Posts: 312
tinfanide is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
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.
Reply With Quote