I'm trying to make a macro to remove certain elements from the subject lines of my selected emails, and I've hit a snag. My code so far is below, cobbled together from everything I could find. It works, kind of. The whole idea is to change all of the items I've selected, but no matter what I do it only changes the first one. I'm sure I'm missing something, but can't figure it out. Any help would be appreciated.
AFTER I get the "do all" part fixed, next step would be to have input boxes so users could input the change and replacement text. Haven't had a chance yet to work on that part.
Thanks,
John
Sub ReplaceInSubjectline()
Dim mySubject As String
Dim myOlExp As Outlook.Explorer
Dim myOlSel As Outlook.Selection
Dim X As Long
Set myOlExp = Application.ActiveExplorer
Set myOlSel = myOlExp.Selection 'The big selection
For X = 1 To myOlSel.Count
Set MyOlSelection = Application.ActiveExplorer.Selection ' Select email
mySubject = Replace(MyOlSelection(X).Subject, "[spam] [MARKETING] ", "")
MyOlSelection(X).Subject = mySubject
Next X
End Sub
Bookmarks