Hi Everyone,
Hope you're well
I have a macro that I am running trying to save an attachment into a specific folder. Its working well except for one part.
'examine each attachment in folder - only saves emails with excel attachments
If SubFolder.Items.Count > 0 Then
For Each Item In SubFolder.Items
For Each Atmt In Item.Attachments
If Right(Atmt.FileName, 3) = "xls" Then
'Here: This is suppose to save the file name with yesterdays date but instead of it saving as "File 20150303.xls" it's saving as
"File.xls20150303.xls"
FileName = "\\Server\Serverfolder\Folder1\Folder2\Folder3\Folder4\March 2015\" & Atmt.FileName & Format(Date - 1, "yyyymmdd") & ".xls"
' The rest in fine. I just thought I'd add this too for more detail
Atmt.SaveAsFile FileName
i = i + 1
End If
Next Atmt
Next Item
'summary measures of actions
If i > 0 Then
MsgBox "I found " & i & " attached files." _
& vbCrLf & "I have saved them into the Folder4\March 2015\ folder" _
& vbCrLf & vbCrLf & "Have a nice day.", vbInformation, "Finished!"
I need it to save as Filename 20150303.xls but I have no idea why it's not doing that.
Please help.
Thank you in advanced
Hope you're well

I have a macro that I am running trying to save an attachment into a specific folder. Its working well except for one part.
'examine each attachment in folder - only saves emails with excel attachments
If SubFolder.Items.Count > 0 Then
For Each Item In SubFolder.Items
For Each Atmt In Item.Attachments
If Right(Atmt.FileName, 3) = "xls" Then
'Here: This is suppose to save the file name with yesterdays date but instead of it saving as "File 20150303.xls" it's saving as
"File.xls20150303.xls"
FileName = "\\Server\Serverfolder\Folder1\Folder2\Folder3\Folder4\March 2015\" & Atmt.FileName & Format(Date - 1, "yyyymmdd") & ".xls"
' The rest in fine. I just thought I'd add this too for more detail
Atmt.SaveAsFile FileName
i = i + 1
End If
Next Atmt
Next Item
'summary measures of actions
If i > 0 Then
MsgBox "I found " & i & " attached files." _
& vbCrLf & "I have saved them into the Folder4\March 2015\ folder" _
& vbCrLf & vbCrLf & "Have a nice day.", vbInformation, "Finished!"
I need it to save as Filename 20150303.xls but I have no idea why it's not doing that.
Please help.
Thank you in advanced