Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2009-04-13
3
Medium Priority
?
224 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article describes how to import an Outlook PST file to Office 365 using a third party product to avoid Microsoft's Azure command line tool, saving you time.
In this article I discuss my selections of the Top Four free Outlook OST File Viewers available. Open, view and read even damaged OST files by using these tools. They all provide a clear preview of all data such as emails, notes, tasks, calendars, e…
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 …
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: …

636 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