Note: The other languages of the website are Google-translated. Back to English
Log in  \/ 
Register  \/ 


How to open specific Excel file from Outlook?

If you want to use a specific Excel file frequently when working on Outlook, so you need to open this file now and then. Is there any quick and easy way for you to open a specified workbook file from Outlook? This article, I will talk about how to solve it.

Open a specific Excel file from Outlook with VBA code

Open a specific Excel file from Outlook with VBA code

You can use the following VBA code to open a default workbook file as you need, please do as this:

1. In Outlook, hold down the ALT + F11 keys to open the Microsoft Visual Basic for Applications window.

2. Then, click Insert > Module, and paste the following code in the Module Window.

VBA code: Open a specific Excel file from Outlook:

Public Sub OpenSpecificExcelWorkbook()
    Dim xExcelFile As String
    Dim xExcelApp As Excel.Application
    Dim xWb As Excel.Workbook
    Dim xWs As Excel.Worksheet
   Dim xExcelRange As Excel.Range
    xExcelFile = "C:\Users\DT168\Desktop\split document\kto-data.xlsx"
    Set xExcelApp = CreateObject("Excel.Application")
    Set xWb = xExcelApp.Workbooks.Open(xExcelFile)
    Set xWs = xWb.Sheets(1)
    Set xExcelRange = xWs.Range("A1")
    xExcelApp.Visible = True
End Sub

Note: In the above code, you should change the Excel file path: C:\Users\DT168\Desktop\split document\kto-data.xlsx to your own.

3. And then, still in the Microsoft Visual Basic for Applications window, click Tools > References to go to the References-Project1 dialog box, and check Microsoft Excel Object Library option from the Available References list box, see screenshot:

doc open specific excel 1

4. Then, click OK button to exit the dialog, save and close the code window. Now, you should add this code to the Quick Access Toolbar.

5. In main interface of the Outlook, click Customize Quick Access Toolbar icon, and select More Commands, see screenshot:

doc open specific excel 2

6. In the Outlook Options dialog box:

  • (1.) Select Macros from the Choose commands from drop down list;
  • (2.) And then choose the VBA code name which you have inserted just now;
  • (3.) Click Add button to add the code into the Customize Quick Access Toolbar list box.

doc open specific excel 3

7. And then a macro icon is displayed into the Quick Access Toolbar as following screenshot shown. From now on, when you click this button, your specified Excel file will be opened at once.

doc open specific excel 4

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
Say something here...
symbols left.
You are guest
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Dustin · 1 years ago
    Outlook rejects the code immediately with an error. "Compile Error. User defined type not defined." And it zeroes in on "Dim xExcelApp As Excel.Application" as the problem. I literally just copied and pasted it as is into the editor and tried to run it and it fails out immediately.
    • To post as a guest, your comment is unpublished.
      Anthony · 11 months ago
      Did you enable the microsoft excel library first?
  • To post as a guest, your comment is unpublished.
    Gitanshu · 1 years ago
    This works pretty well!

    Could you help me with the line of code in addition to it on how to close the workbook without saving changes.
  • To post as a guest, your comment is unpublished.
    w · 2 years ago
    Or you can run .bat file:

    @echo off
    "C:\Program Files (x86)\Microsoft Office\Office12\EXCEL.EXE" "D:\your_file.xlsx"

    and VBA:
    Set WshShell = CreateObject("WScript.Shell")
    WshShell.Run chr(34) & "D:\your_BAT.bat" & Chr(34), 0
    Set WshShell = Nothing