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:
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.
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 Pro: Batch 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.