Good day
I have a vba code macro that saves a message from outlook inbox to a folder on my desktop.
But I changed from outlook 2007 to outlook 2013 and the macro is no longer working.
When I research the problem , it seems to be a silent error, because even the code doesn't produce an error when I compile it.
It seems in 2o13 outlook I have to use ribbon extensibility to solve the problem and I don't know how to do that.
Below is my code, please assist.
Option Explicit
Public Sub SaveMessageAsMsg()
Dim oMail As Outlook.MailItem
Dim myNamespace As Outlook.NameSpace
Dim myFolder As Outlook.Folder
Dim objItem As Object
Dim sPath As String
Dim dtDate As Date
Dim sName As String
Set myNamespace = Application.GetNamespace("MAPI")
Set myFolder = myNamespace.GetDefaultFolder(olFolderInbox)
For Each objItem In myFolder.Items
If objItem.UnRead Then
If objItem.Subject = "FW: signal" Then
oMail = objItem
sName = oMail.Subject
sName = sName & ".msg"
sPath = "C:\Users\User\Desktop\SAS CODE"
oMail.SaveAs sPath & sName, olMSG
End If
End If
Next
End Sub
I have a vba code macro that saves a message from outlook inbox to a folder on my desktop.
But I changed from outlook 2007 to outlook 2013 and the macro is no longer working.
When I research the problem , it seems to be a silent error, because even the code doesn't produce an error when I compile it.
It seems in 2o13 outlook I have to use ribbon extensibility to solve the problem and I don't know how to do that.
Below is my code, please assist.
Option Explicit
Public Sub SaveMessageAsMsg()
Dim oMail As Outlook.MailItem
Dim myNamespace As Outlook.NameSpace
Dim myFolder As Outlook.Folder
Dim objItem As Object
Dim sPath As String
Dim dtDate As Date
Dim sName As String
Set myNamespace = Application.GetNamespace("MAPI")
Set myFolder = myNamespace.GetDefaultFolder(olFolderInbox)
For Each objItem In myFolder.Items
If objItem.UnRead Then
If objItem.Subject = "FW: signal" Then
oMail = objItem
sName = oMail.Subject
sName = sName & ".msg"
sPath = "C:\Users\User\Desktop\SAS CODE"
oMail.SaveAs sPath & sName, olMSG
End If
End If
Next
End Sub