Solved

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

Posted on 2009-04-13
3
217 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Resolve DNS query failed errors for Exchange
This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
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…

770 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