How to save only specific (excel) attachment in Outlook?
Outlook provides a Save All Attachments feature for you to quickly save all attachments in an email to a specific folder at once. However, if you want to save only specific type of attachment in an email, such as Excel attachment, Word document and so on, what can you do to achieve it? Here we provide a VBA method to solve the problem.
Office Tab: Enable Tabbed Editing and Browsing in Office, Just Like Chrome, Firefox, IE 8/9/10.
Classic Menu: Bring Old Menus and Toolbars Back to Office 2007, 2010, 2013, 2016 and 2019.
The below VBA code can help to save only specific attachment in an email or multiple emails to a specific folder. Please do as follows.
1. Launch your Outlook, in the mailing list, select an email or multiple emails you will save specific attachment from.
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 20181130 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 & "<br>" & "<a href='file://" & xFilePath & "'>" & xFilePath & "</a>" End If End If Next If xItem.BodyFormat <> olFormatHTML Then xItem.Body = vbCrLf & "The file(s) were saved to " & xFilesSavePath & vbCrLf & xItem.Body Else xItem.HTMLBody = "<p>" & "The file(s) were saved to " & xFilesSavePath & "</p>" & xItem.HTMLBody End If 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.
Then only the specified attachments are saved.
1. If you want to save different type of attachments, please enter the file extensions into the text box and separate them by comma.
2. After saving, an attachment saving path is displayed on the message body. You can open the attachment by clicking the hyperlink directly.
- How to save all attachments from email messages in Outlook?
- How to remove all attachments from email in Outlook?
Kutools for Outlook
More than 100 Advanced Functions for Outlook 2010, 2013, 2016, 2019 and 365