3

In my work I handle over a hundred emails in a day and I always have to add my initials to the front of the subject so others know that I have taken it.

Currently in Outlook 2013 I have to double click the email, mouseclick to the front of the subject, add my initials and /, and then close the email and answer yes to the question "Do you want to change the subject."

I have tried to create a vba button for doing this for me, code is below, but I just can't get it to work. The Error code while running from editor is: Run-time error '424': Object required. while using macrobutton in outlook, absolutely nothing happens. Macro security is set to notify.

So, any help or complete rewriting of the code would be much appreciated!

Sub Nimmarit()
Dim aItem As Object

Set aItem = obj.AppApplication.ActiveExplorer.Selection()

Dim strTemp As String
Dim strFilenum As String

strFilenum = "JK/"

If strFilenum = False Then Exit Sub
If strFilenum = "" Then Exit Sub

strTemp = "[" & strFilenum & "] " & aItem.Subject
    aItem.Subject = strTemp
    aItem.Save     
End Sub
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
JKurki
  • 33
  • 5

1 Answers1

1

Try the following

Sub Nimmarit()
    Dim olItem As MailItem
    Dim sFilenum As String

    sFilenum = "JK/ "

    If Application.ActiveExplorer.Selection.Count = 0 Then
        MsgBox "No Items selected!", vbCritical, "Error"
    End If

    '// Process each selected Mail Item
    For Each olItem In Application.ActiveExplorer.Selection
        olItem.Subject = "[" & sFilenum & "] " & olItem.Subject
        olItem.Save
    Next olItem
End Sub
0m3r
  • 12,286
  • 15
  • 35
  • 71