Solved

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

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Find out how to use dynamic social media in email signatures with this top 10 DOs & DON’Ts.
Create high volume marketing opportunities using email signatures with these top 10 DOs and DON'Ts of email signature marketing.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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 …

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now