View Single Post
 
Old 04-17-2012, 10:25 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,365
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi tinfanide,

Try this version:
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"
      .Execute
    End With
    If .Find.Found Then
      Set Rng = .Duplicate.Paragraphs.Last.Next.Range
      With Rng
        While Not .Characters.Last Like "[a-z]"
          .End = .End - 1
        Wend
        Str1 = Trim(.Text)
      End With
    End If
  End With
  With .Content
    With .Find
      .ClearFormatting
      .MatchWildcards = True
      .Text = "RE: [!13]@^13"
      .Execute
    End With
    If .Find.Found Then
      Set Rng = .Duplicate
      With Rng
        While Not .Characters.Last Like "[a-z]"
          .End = .End - 1
        Wend
        .Start = .Start + 4
        Str2 = Trim(.Text)
      End With
    End If
  End With
  MsgBox .Path & "\" & Str1 & " " & Str2
  '.SaveAs2 FileName:=ThisDocument.Path & "\" & Str1 & " " & Str2, FileFormat:=wdFormatDocumentDefault
End With
End Sub
if you get a message box with the correct contents, you can delete that line and uncomment the next line.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote