2016-03-04 64 views
2

在我的工作中,我每天處理一百封電子郵件,而且我總是必須在主題前加上我的首字母縮寫,以便其他人知道我已經接受了它。修改選定的電子郵件主題

目前在Outlook 2013中,我必須雙擊電子郵件,鼠標點擊主題的前面,添加我的姓名縮寫和/,然後關閉電子郵件並回答「是否要更改主題。 「

我試圖創建一個vba按鈕爲我做這個,代碼是在下面,但我只是不能得到它的工作。從編輯器運行時的錯誤代碼是:運行時錯誤'424':需要對象。而在Outlook中使用macrobutton時,絕對沒有任何反應。宏安全設置爲通知。

因此,任何幫助或完整的代碼重寫將不勝感激!

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 

回答

0

請嘗試以下

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