Skip to main content

How To Quickly Open The File Dialog Box To Insert An Attachment In Outlook?

When we need to insert an attachment in a composing email, usually we need to click Insert > Attach File > Browse This PC to open the Insert File dialog box, then find and insert the file we need. In this tutorial, we provide two VBA codes to help you open the Insert File dialog box easily with just one click.


Quickly Open The File Dialog Box To Insert An Attachment With VBA

The following VBA codes can achieve:

VBA code 1: Open the default Documents folder in your computer
VBA code 2: Open the specified folder in your computer

Please do as follows to get it done.

1. Launch your Outlook, press the Alt + F11 keys to open the Microsoft Visual Basic for Applications window.

2. In the Microsoft Visual Basic for Applications window, click Tools > References, then check the Microsoft Scripting Runtime box in the References – Project1 dialog box.

3. Click Insert > Module. Then copy one of the following VBA codes to the Module window.

VBA code 1: Open the default Documents folder in your computer

Sub OpenFileDialog()
'Updated by Extendoffice 20220713
Dim xApp As Object
Dim xFileDlg As FileDialog
Dim xSelItem As Variant
Dim xMail As MailItem
On Error Resume Next
Set xApp = CreateObject("Excel.Application")
xApp.Visible = False
Set xFileDlg = xApp.Application.FileDialog(msoFileDialogFilePicker)
xFileDlg.AllowMultiSelect = True
If xFileDlg.Show = 0 Then Exit Sub
Set xMail = Application.ActiveInspector.currentItem
For Each xSelItem In xFileDlg.SelectedItems
    xMail.Attachments.Add xSelItem
Next
xApp.Quit
Set xFileDlg = Nothing
Set xApp = Nothing
End Sub

VBA code 2: Open the specified folder in your computer

Sub OpenCertianFolderDialog()
'Updated by Extendoffice 20220713
Dim xApp As Object
Dim xFileDlg As FileDialog
Dim xSelItem As Variant
Dim xMail As MailItem
On Error Resume Next
Set xApp = CreateObject("Excel.Application")
xApp.Visible = False
Set xFileDlg = xApp.Application.FileDialog(msoFileDialogFilePicker)
xFileDlg.InitialFileName = "C:\Users\Win10x64Test\Desktop\save attachments\"  'Specify the path to the folder you want to open
xFileDlg.AllowMultiSelect = True
If xFileDlg.Show = 0 Then GoTo L1
Set xMail = Application.ActiveInspector.CurrentItem
For Each xSelItem In xFileDlg.SelectedItems
    xMail.Attachments.Add xSelItem
Next
L1:
    xApp.Quit
    Set xFileDlg = Nothing
    Set xApp = Nothing
End Sub

Notes:

1) The VBA code 1 helps to open the default Documents folder in your computer.
2) In the VBA code 2, please change the folder path in the following line to the folder path you need.
xFileDlg.InitialFileName = "C:\Users\Win10x64Test\Desktop\save attachments\"
Then the specified folder will be opened each time you run this code.

4. Press the Alt + Q keys to close the Microsoft Visual Basic for Applications window.

Now you need a button to run the macro.

5. Click Home > New Email to create a new email. In the message window, click Customize Quick Access Toolbar > More Commands.

6. In the Outlook Options dialog box, you need to configure as follows.

6.1) In the Choose commands from drop-down list, select Macros;
6.2) Select the macro you added in the previous step;
6.3) Click the Add button to add this macro to the Customize Quick Access Toolbar box.

7. Keep the script selected in the right box, and then click the Modify button. In the Modify Button dialog box, assign a new button to the script and click OK.

8. Click OK in the Outlook Options dialog box to save the changes.

9. The button you specified in step 7 is then added to the Quick Access Toolbar. When composing an email, if you want to insert an attachment, you can just click on this button to open the Browse folder and select the file you need to insert.


Best Office Productivity Tools

Kutools for Outlook - Over 100 Powerful Features to Supercharge Your Outlook

πŸ€– AI Mail Assistant: Instant pro emails with AI magic--one-click to genius replies, perfect tone, multilingual mastery. Transform emailing effortlessly! ...

πŸ“§ 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 ...

πŸ“¨ Email Management: Easily Recall Emails  /  Block Scam Emails by Subjects and Others  /  Delete Duplicate Emails  /  Advanced Search  /  Consolidate Folders ...

πŸ“ Attachments ProBatch Save  /  Batch Detach  /  Batch Compress  /  Auto Save   /  Auto Detach  /  Auto Compress ...

🌟 Interface Magic: 😊More Pretty and Cool Emojis   /  Boost Your Outlook Productivity with Tabbed Views  /  Minimize Outlook Instead of Closing ...

πŸ‘ One-click Wonders: Reply All with Incoming Attachments  /   Anti-Phishing Emails  /  πŸ•˜Show Sender's Time Zone ...

πŸ‘©πŸΌβ€πŸ€β€πŸ‘©πŸ» Contacts & Calendar: Batch Add Contacts From Selected Emails  /  Split a Contact Group to Individual Groups  /  Remove Birthday Reminders ...

Over 100 Features Await Your Exploration! Click Here to Discover More.

Read More       Free Download      Purchase
 

 

Comments (0)
No ratings yet. Be the first to rate!
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
Rate this post:
0   Characters
Suggested Locations