How To Save Only Specific (Excel) Attachment In Outlook?
Outlook provides the Save All Attachments feature to help you saving all attachments in an email to a specific folder at one time. However, if you want to save only certain types of attachments in one or more emails, such as Excel workbooks, Word documents and so on, how do you achieve it? In this tutorial, we provide you two methods to solve this problem.
The following VBA code can help to save only specific file format attachments in one or more selected emails to a specific folder. Please do as follows.
1. Launch your Outlook. In the Mail list, select one or more emails from which you want to save only attachments in a specific file format.
2. Press the Alt + F11 keys to open the Microsoft Visual Basic for Applications window. In the opening window, click Insert > Module, and then copy below VBA code into the Module window.
VBA code: Save only specific attachment in an email or multiple emails to a folder
Public Sub SaveSpecifyAttachments() 'Updated by ExtendOffice 20210617 Dim xItem As Object, xFldObj As Object Dim xSelection As Selection Dim xAttachment As Outlook.Attachment Dim xSaveFolder As String Dim xFSO As Scripting.FileSystemObject Dim xFilePath, xFilesSavePath As String Dim xExtStr As String, xExt As String Dim xExtArr() As String, xS As Variant On Error Resume Next Set xFldObj = CreateObject("Shell.Application").BrowseforFolder(0, "Select a Folder", 0, 16) Set xFSO = New Scripting.FileSystemObject If xFldObj Is Nothing Then Exit Sub xSaveFolder = xFldObj.Items.Item.Path & "\" Set xSelection = Outlook.Application.ActiveExplorer.Selection xExtStr = InputBox("Attachment Format:" + VBA.vbCrLf + "(Please separate multiple file extensions by comma.. Such as: .docx,.xlsx)", "Kutools for Outlook", xExtStr) If Len(Trim(xExtStr)) = 0 Then Exit Sub For Each xItem In xSelection If xItem.Class = olMail Then xFilesSavePath = "" For Each xAttachment In xItem.Attachments xFilePath = xSaveFolder & xAttachment.FileName xExt = "." & xFSO.GetExtensionName(xFilePath) xExtArr = VBA.Split(xExtStr, ",") xS = VBA.Filter(xExtArr, xExt) If UBound(xS) > -1 Then xAttachment.SaveAsFile xFilePath If xItem.BodyFormat <> olFormatHTML Then xFilesSavePath = xFilesSavePath & vbCrLf & "<file://" & xFilePath & ">" Else xFilesSavePath = xFilesSavePath & "
" & "" & xFilePath & "" End If End If Next xItem.Save End If Next Set xFSO = Nothing End Sub
3. Click Tools > References, in the References – Project dialog, check the Microsoft Scripting Runtime box and click the OK button.
4. Press the F5 key to run the code. In the popped out Browse for Folder dialog box, choose one folder to save the attachments.
5. And then, click OK, in the following Kutools for Outlook dialog box, enter the file extension of the attachment you will save into the text box and click OK.
Note: For multiple file extensions, you need to separate them with commas.
Then only the specified attachments are saved.
If you are new to VBA, here we recommend you to use the Save All attachments feature of Kutools for Outlook. With this feature, you can easily save only attachments in a specific file format in Outlook.
1. Select the emails from which you want to save only attachments in a specific file format.
2. Click Kutools > Attachment Tools > Save All.
3. In the Save Settings dialog box, you need to configure as follows.
4. A dialog box pops up reminding you if you want to save the attachments, click OK to continue.
5. Then another dialog box pops up to tell you how many attachments have been saved, click the OK button.
Now only the specific file format attachments are saved.
Click here to know more about this feature.
- How to save all attachments from email messages in Outlook?
- How to remove all attachments from email in Outlook?
Best Office Productivity Tools
Kutools for Outlook - Over 100 Powerful Features to Supercharge Your Outlook
📧 Email Automation: Out of Office (Available for POP and IMAP) / Schedule Send Emails / Auto CC/BCC by Rules When Sending Email / Auto Forward (Advanced Rules) / Auto Add Greeting / Automatically Split Multi-Recipient Emails into Individual Messages ...
Over 100 Features Await Your Exploration! Click Here to Discover More.