本文介绍了用于从Outlook下载Excel文件的VBA代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用的是Outlook 2010.我每天收到6封电子邮件,每封都有一个不同的Excel .csv文件。是否有可用于将每个VBA代码下载到文件夹中的VBA代码。这些将覆盖前几天的文件。
I use Outlook 2010. I receive 6 emails on a daily basis, each with a different excel .csv file. Is there a VBA code I can use to download each of them into a folder. These would overwrite the previous days files.
谢谢
推荐答案
Sub CustomSaveAttachments(Item As Outlook.MailItem)
Dim olAtt As Attachment
Dim strFilename As String
Const strPath As String = "C:\Path\" 'The folder in which you want to save the files
If Item.Attachments.Count > 0 Then
For Each olAtt In Item.Attachments
If Right(LCase(olAtt.FileName), 3) = "csv" Then
strFilename = strPath & olAtt.FileName
olAtt.SaveAsFile strFilename
End If
Next olAtt
End If
lbl_Exit:
Exit Sub
End Sub
这篇关于用于从Outlook下载Excel文件的VBA代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!