?
Solved

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

Posted on 2009-04-13
3
Medium Priority
?
223 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 76

Accepted Solution

by:
David Lee earned 2000 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

If you troubleshoot Outlook for clients, you may want to know a bit more about the OST file before doing your next job. IMAP can cause a lot of drama if removed in the accounts without backing up.
This article describes how to import Lotus Notes Contacts into Outlook 2016, 2013, 2010 and 2007 etc. with a few manual steps. You can easily export and migrate Lotus Notes contacts into Microsoft Outlook without having to use any third party tools.
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…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
Suggested Courses

801 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