I don't have time to go in to how to download an attachment, but here is a function that will do what you want.
Function ReNameFile(FileName As String, NumChar As Long) As String
' FileName is the file name
' Numchar is the number of characters to remove from the end
Dim StrArray() As String
StrArray = Split(FileName, ".")
StrArray(0) = Left(StrArray(0), Len(StrArray(0)) - NumChar)
ReNameFile = Join(StrArray, ".")
End Function
Sub Test1()
MsgBox ReNameFile("report_20170831070501.csv", 2)
End Sub
Sub Test2()
MsgBox ReNameFile("This Report_2017-08-31-05-41-56.xlsx", 9)
End Sub
Bookmarks