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.
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) xWs.Activate Set xExcelRange = xWs.Range("A1") xExcelRange.Activate 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:
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:
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.
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.
Kutools for Outlook
More than 100 Advanced Functions for Outlook 2010, 2013, 2016, 2019 and 365