For each reply in Outlook, I need to remove the text in the body of the message starting with the word "From" through the word "Support." I recorded the Macro in Word but I can't get it to work in Outlook. I also need to delete the information appearing between the two forward slashes that appear in the body of the message (in only the first instance.) and leave one in its place. Can anyone help me amend the code below to get this to work? Thank you in advance!
Sub Clean()
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "From:*support"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Find.ClearFormatting
With Selection.Find
.Text = "/*/"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute
Selection.Find.Execute
Selection.Find.Execute
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.TypeText Text:="/"
End Sub
Looking online I thought the following code might do the trick, however, I am still having issues...
Sub Clean()
Dim objDoc As Word.Document
Dim objWord As Word.Application
Dim objRange As Word.Range
Set objDoc = ActiveInspector.WordEditor
Set objWord = objDoc.Application
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "From:*support"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Find.ClearFormatting
With Selection.Find
.Text = "/*/"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute
Selection.Find.Execute
Selection.Find.Execute
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.TypeText Text:="/"
End Sub
Sub Clean()
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "From:*support"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Find.ClearFormatting
With Selection.Find
.Text = "/*/"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute
Selection.Find.Execute
Selection.Find.Execute
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.TypeText Text:="/"
End Sub
Looking online I thought the following code might do the trick, however, I am still having issues...
Sub Clean()
Dim objDoc As Word.Document
Dim objWord As Word.Application
Dim objRange As Word.Range
Set objDoc = ActiveInspector.WordEditor
Set objWord = objDoc.Application
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "From:*support"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Find.ClearFormatting
With Selection.Find
.Text = "/*/"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute
Selection.Find.Execute
Selection.Find.Execute
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.TypeText Text:="/"
End Sub