Solved

Mass e-mail subject renaming macro run-time error 13

Posted on 2009-04-13
3
220 Views
Last Modified: 2012-05-06
I recently added this macro to my 2003 outlook visual basic editor.  It has been a real Godsend and has been exactly what I have been looking for after months of searching.  Thank You Blue Devil Fan for the code.

The macro worked flawlessly for weeks, then all of the sudden I am getting the following message:

Run-time err '13'

Type mismatch

The macro then gives me the option to debug the code.  When that is selected, the visual basic editor highlights code line #16, which is the last "Next" in the code.

I researched this problem, and Microsoft recommended installing service pack #3 for Office 2003, and service pack #3 for Windows XP.  I did both and nothing is working.  

I desperately need this macro to work again.

Please let me know if you have any recommendations.

Thank You Expert!
Sub FixSubjectLineV2()
    Const MACRONAME = "Fix Subject Line"
    Dim olkMsg As Outlook.MailItem, _
        olkItems As Outlook.Items, _
        strSubject As String, _
        strNewSub As String
    strSubject = InputBox("What word/phrase do you want me to search for?", MACRONAME)
    strNewSub = InputBox("What text do you want to replace the word/phrase with?", MACRONAME)
    If strSubject <> "" Then
        Set olkItems = Application.ActiveExplorer.CurrentFolder.Items
        For Each olkMsg In olkItems
            If InStr(1, olkMsg.Subject, strSubject) Then
                olkMsg.Subject = Replace(olkMsg.Subject, strSubject, strNewSub)
                olkMsg.Save
            End If
        Next
    End If
    Set olkItems = Nothing
    Set olkMsg = Nothing
    MsgBox "All done!", vbInformation + vbOKOnly, MACRONAME
End Sub

Open in new window

0
Comment
Question by:jrehrman
  • 2
3 Comments
 
LVL 76

Accepted Solution

by:
David Lee earned 500 total points
ID: 24133254
Hi, jrehman.

The problem is almost certainly caused by a non-mail item in the folder your processing.  For example a read receipt or delivery report.  There are two ways to cure this.  

1.  Make sure the folder only contains mail items.
2.  Change "Outlook.MailItem" on line 3 to "Object".

You're welcome for the code.  I'm glad you found it useful.
0
 

Author Closing Comment

by:jrehrman
ID: 31569687
Thank You Thank You Thank You!!!

Thank You so much for quick response.

I opted for solution number 2 and it works awweessoommee!!!

:-)

I look forward to being productive again.

Thank You Blue Devil Fan!

0
 
LVL 76

Expert Comment

by:David Lee
ID: 24133960
You're welcome!
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
Many of my clients call in with monstrous Gmail overloading issues with Outlook. A quick tip is to turn off the All Mail and Important folders from synching. Here is a quick video I made to show you how to turn off these and other folders in Gmail s…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question