Okay So I keep trying to run the following code with no luck. I just want to auto save the files to the file path mentioned below when the subject line is: Report: Advancement Transaction Detail
and I am not savvy in VBA so please dumb it down for me.
My File path is:
R:\Departments\Budget Services\Authorized Access Only\FY18 Budget\DB Management\Transactions Detail
and I am not savvy in VBA so please dumb it down for me.
Code:
Public Sub SaveMsg(Item As Outlook.MailItem)
Dim sPath As String
Dim dtDate As Date
Dim sName As String
Dim enviro As String
enviro = CStr(Environ("USERPROFILE"))
sName = Item.Subject
ReplaceCharsForFileName sName, "Report: Advancement Transaction Detail"
dtDate = Item.ReceivedTime
sName = Format(dtDate, "yyyymmdd", vbUseSystemDayOfWeek, _
vbUseSystem) & Format(dtDate, "-hhnnss", _
vbUseSystemDayOfWeek, vbUseSystem) & "-" & sName & ".msg"
' use My Documents in older Windows.
sPath = enviro & "\Documents\"
Debug.Print sPath & sName
Item.SaveAs sPath & sName, olMSG
End Sub
Private Sub ReplaceCharsForFileName(sName As String, _
sChr As String _
)
sName = Replace(sName, "/", sChr)
sName = Replace(sName, "\", sChr)
sName = Replace(sName, ":", sChr)
sName = Replace(sName, "?", sChr)
sName = Replace(sName, Chr(34), sChr)
sName = Replace(sName, "<", sChr)
sName = Replace(sName, ">", sChr)
sName = Replace(sName, "|", sChr)
End Sub
My File path is:
R:\Departments\Budget Services\Authorized Access Only\FY18 Budget\DB Management\Transactions Detail