Tosborn
New Member
- Joined
- May 24, 2016
- Messages
- 44
Hi all,
I'm using the following piece of VBA in outlook to save a file when it is received automatically however the file is unusable.
If I don't change the name of the file when saving in the directory it is ok but because the file names can be different at times the VBA changes the file name and this results in corruption. The file name changes but not the extension.
Any ideas?
Cheers,
Tim
I'm using the following piece of VBA in outlook to save a file when it is received automatically however the file is unusable.
If I don't change the name of the file when saving in the directory it is ok but because the file names can be different at times the VBA changes the file name and this results in corruption. The file name changes but not the extension.
Any ideas?
Code:
'Outlook code
'save all attachments
Public Sub SaveAllAttach(itm As Outlook.MailItem)
Dim objAtt As Outlook.Attachment
Dim saveFolder As String
saveFolder = "M:\Sales Team\Budgets\FY 2016_17"
'saveFolder = "H:"
For Each objAtt In itm.Attachments
'to save as original file name - this works ok
'objAtt.SaveAsFile saveFolder & "\" & objAtt.DisplayName
'to save as specified filename - currently using this, which corrupts the file
objAtt.SaveAsFile saveFolder & "\" & "Forecast Funding Report Summary.xlsx"
Set objAtt = Nothing
Next
End Sub
Cheers,
Tim