This is File1.
This is File2.
Example 1 – Open a Secondary Workbook in the Background with Excel VBA
STEPS:
- Go to the Developer tab.
- Select Visual Basic.
- In the VBA window, double-click ThisWorkbook in VBAProject (File1.xlsm).
- Enter the following code.
Private Sub Workbook_Open()
Application.ScreenUpdating = True
Workbooks.Open Filename:="D:\46\excel vba open workbook in background\File2.xlsx"
ThisWorkbook.Activate
Application.ScreenUpdating = False
End Sub
- Save the file.
- Close File1.
- Open File1 again.
- File2 will open in the background.
Read More: How to Open Workbook as Read-Only with Excel VBA
Example 2 – Using a VBA Code to Open an Excel Workbook Without Showing it
STEPS:
- Go to Developer ➤ Visual Basic.
- In the VBA window, click Module.
- Enter the code below .
Sub Open_Workbook()
Application.ScreenUpdating = True
Workbooks.Open Filename:="D:\46\excel vba open workbook in background\File2.xlsx"
ThisWorkbook.Activate
Application.ScreenUpdating = False
End Sub
- Save the code by pressing Ctrl+S.
- Close the VBA window.
- Go to the Developer tab.
- Click Macros.
- In the Macro dialog box, choose Open-Workbook in Macro name.
- Click Run.
It will open File2 in the background.
Read More: How to Open Workbook and Run Macro Using VBA
Download Practice Workbook
Download the following workbook.
Related Articles
- How to Open Workbook with Variable Name with Excel VBA
- How to Open Workbook from Path Using Excel VBA
- Excel VBA to Open Workbook from Path in Cell
- How to Browse for File Path Using Excel VBA
- How to Open Folder and Select File Using Excel VBA
- How to Open File Dialog Default Folder with Excel VBA
The first Application.Screenupdating should be set to False.
Hello Rolan,
Thanks for your suggestion. Article is updated.