Note: The other languages of the website are Google-translated. Back to English

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.

Save only specific file format attachments in Outlook with VBA code
Easily save only specific file format attachments in Outlook with an amazing tool


Save only specific file format attachments in Outlook with VBA code

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.


Easily save only specific file format attachments in Outlook with an amazing tool

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.

3.1) In the Save attachment(s) to this folder section, click the button to select a folder to save the attachments;
3.2) Click the Advanced options button to unfold the dialog box;
3.3) In the Filter conditions section, check the Attachment type checkbox, then enter the file extension of the attachments you will save into the text.
Tips: For multiple file extensions, you need to separate them with semicolons.
3.4) Click the OK button. See screenshot:

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.

  If you want to have a free trial ( 30-day) of this utility, please click to download it, and then go to apply the operation according above steps.


Related articles:


Kutools for Outlook - Brings 100 Advanced Features to Outlook, and Make Work Much Easier!

  • Auto CC/BCC by rules when sending email; Auto Forward Multiple Emails by custom; Auto Reply without exchange server, and more automatic features...
  • BCC Warning - show message when you try to reply all if your mail address is in the BCC list; Remind When Missing Attachments, and more remind features...
  • Reply (All) With All Attachments in the mail conversation; Reply Many Emails in seconds; Auto Add Greeting when reply; Add Date into subject...
  • Attachment Tools: Manage All Attachments in All Mails, Auto Detach, Compress All, Rename All, Save All... Quick Report, Count Selected Mails...
  • Powerful Junk Emails by custom; Remove Duplicate Mails and Contacts... Enable you to do smarter, faster and better in Outlook.
shot kutools outlook kutools tab 1180x121
shot kutools outlook kutools plus tab 1180x121
 
Comments (0)
No ratings yet. Be the first to rate!
There are no comments posted here yet
Leave your comments
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations