Excel VBA: Open a Workbook in the Background, Hidden

VBA & macros · Updated November 3, 2026

Excel VBA: Open a Workbook in the Background, Hidden

Yes. In Excel VBA, open the file with Workbooks.Open, then set each window in the returned workbook’s Windows collection to Visible = False. Turning off Application.ScreenUpdating while you do this can reduce flicker, but it does not, by itself, make the workbook hidden.

What “open in the background” means in Excel

Excel does not have a single Workbooks.Open argument that means “open this workbook invisibly.” Opening and displaying are separate matters: Workbooks.Open loads the workbook into an Excel application instance, while the workbook’s window determines whether its sheets are shown. VBA can therefore keep a workbook loaded and usable while hiding its window.

A hidden workbook is not closed, protected, or inaccessible to code. Your macro can still read cells, write values, calculate formulas, and refer to worksheets. A person using the same Excel instance may not see the workbook’s sheets, but the workbook remains part of that instance and can still affect file locks, memory use, links, and calculations.

There are two common goals that people describe as “background” work:

  • Keep the workbook open but out of sight: hide its window and continue using it from VBA.
  • Process it and finish: open it, perform the required work, save or discard changes deliberately, then close it.

The first is useful when a macro needs to use the workbook later. The second is usually preferable for a one-time import or report task because it releases the workbook and its file lock when finished.

A basic VBA pattern for opening a hidden workbook

This example opens a workbook read-only, prevents external links from updating during the open, hides its workbook windows, and leaves it open for further VBA work. Replace the example path with a real path accessible from your computer. Save a copy of the workbook before running a macro: VBA changes cannot be undone with Ctrl+Z.

Sub OpenWorkbookHidden()
    Dim wb As Workbook
    Dim wbWindow As Window
    Dim filePath As String
    Dim previousScreenUpdating As Boolean
    Dim errorText As String

    ' Replace this with the workbook's full path.
    filePath = "C:\Reports\Source.xlsx"
    previousScreenUpdating = Application.ScreenUpdating

    On Error GoTo OpenFailed
    Application.ScreenUpdating = False

    ' ReadOnly avoids editing the source; UpdateLinks:=0 skips link updates.
    Set wb = Workbooks.Open(Filename:=filePath, ReadOnly:=True, UpdateLinks:=0)

    ' Hide every window belonging to this workbook.
    For Each wbWindow In wb.Windows
        wbWindow.Visible = False
    Next wbWindow

CleanUp:
    Application.ScreenUpdating = previousScreenUpdating
    Exit Sub

OpenFailed:
    errorText = Err.Description
    On Error Resume Next
    If Not wb Is Nothing Then wb.Close SaveChanges:=False
    Application.ScreenUpdating = previousScreenUpdating
    On Error GoTo 0
    MsgBox "Could not open the workbook: " & errorText, vbExclamation
End Sub

After the procedure succeeds, the workbook is still open and available through the wb variable while the procedure is running. If later procedures need to find it, store a reference in a suitably scoped variable or identify it by name. To close it when processing is complete, use wb.Close SaveChanges:=False to discard changes, or save deliberately before closing. Do not use the discard option if the macro’s changes are meant to be kept.

The example uses ReadOnly:=True because it is a cautious default for processing a source file. Remove that argument only when the macro needs to edit the workbook and the file can safely be opened for editing. UpdateLinks:=0 also has a consequence: linked values may remain at their saved values rather than being refreshed. Choose link behavior according to the task.

Keep the workbook hidden while you work with it

Hiding the window does not prevent VBA from referring to the workbook. For example, after opening it, code can read a cell with an expression such as wb.Worksheets("Data").Range("A1").Value. Qualifying the worksheet and range with the workbook variable matters: an unqualified reference such as Range("A1") can point to the active sheet in a different workbook.

When the macro is finished, decide explicitly what should happen to the hidden file. If it was opened read-only for inspection, closing without saving is generally consistent with that purpose. If the macro changed data, save only when intended; do not assume hiding the window saves or protects anything. A hidden workbook can also be made visible again by setting its window’s Visible property to True.

A workbook can have more than one window, for example if someone has created a second view. Hiding only wb.Windows(1) may leave another window visible. The loop in the example handles all windows that belong to the workbook. Conversely, if there is no window available, code that assumes a first window exists can fail, which is one reason to check the workbook’s window collection when adapting the procedure.

ScreenUpdating is not the same as hiding a workbook

Application.ScreenUpdating = False tells Excel not to redraw the screen during a macro. It can make a sequence of operations look smoother and may improve performance, but it is an application-level display setting, not a workbook visibility setting. Excel may still have the workbook open and its window visible once screen updating resumes unless the window itself was hidden.

Always restore the setting to the value it had before the procedure. Setting it unconditionally to True at the end can interfere with another macro that had already turned screen updating off. Error handling matters too: if a macro stops before restoring the setting, Excel can appear frozen or fail to refresh until the setting is turned back on. The example stores the previous value and restores it on both the successful and error paths.

For a longer procedure, use a single cleanup section for application settings such as screen updating, calculation mode, or event handling. Change only settings the task actually needs, record their original values first, and restore them even if an error occurs. Avoid turning off several Excel features just to make a workbook invisible; window visibility is the direct control for that job.

Choose between a hidden window and a separate Excel instance

For most macros running inside Excel, hiding the workbook window in the current instance is the simplest option. It avoids creating another Excel process and allows the macro to use the workbook object directly. It also means the hidden workbook shares the current instance’s application settings, such as calculation and event settings.

A separate Excel application instance can provide stronger separation from the Excel window a person is using. On Windows, VBA can create another instance through Automation, set that instance’s Visible property to False, open the workbook there, and close the instance when finished. This approach requires careful cleanup: if the macro exits without closing the workbook and quitting the extra instance, an Excel process may remain running in the background. It can also consume more memory and complicate references between workbooks.

  • Use a hidden workbook window when the task is a normal macro in the current Excel session.
  • Consider a separate instance when isolation from the user’s current workbook or application state is important.
  • Do not create a second instance merely to avoid a brief redraw; first try hiding the workbook window and managing screen updating.

Creating a separate instance using Windows COM automation is not a cross-platform technique. Excel for Mac has different automation and file-path considerations, so Windows-specific instance-creation examples should not be assumed to work there.

Links, macros, prompts, and file safety

Opening a workbook can do more than load cell values. It may involve external links, read-only recommendations, password prompts, compatibility messages, or workbook event procedures. A hidden window does not suppress those behaviors. In particular, hiding a workbook is not a security boundary: it does not make the workbook’s contents secret or prevent its macros from running.

When opening files from VBA, consider the source and trust status of the file. Excel’s Application.AutomationSecurity setting can be used around a programmatic open to control macro behavior; Microsoft Office defines msoAutomationSecurityForceDisable for disabling macros in files opened programmatically. If you change this application-wide setting, save its previous value and restore it after the open, including on error. Disabling macros also means the workbook’s own macro-based behavior will not run, which may or may not suit the task.

Use DisplayAlerts = False cautiously. It suppresses certain Excel prompts and Excel may choose default responses, potentially discarding or changing something the user would otherwise confirm. It does not solve every prompt, and it should not be switched off as a general substitute for handling passwords, links, or file errors. Prefer explicit open arguments and a deliberate error path. For sensitive or important files, test on a copy first.

Common problems and how to diagnose them

  • The workbook still flashes on screen: hiding occurs after Workbooks.Open returns, so the window may be displayed briefly. Turning off screen updating during the open can reduce redraw, but behavior can vary with Excel, add-ins, and workbook events. If a truly separate hidden process is required, investigate a separate instance and its cleanup requirements.
  • The wrong workbook or sheet is being changed: qualify references with the workbook and worksheet variables. Avoid relying on ActiveWorkbook, ActiveSheet, or unqualified Range when multiple files are open.
  • The source file cannot be opened: confirm the path, permissions, file extension, and whether another user or process has locked the file. Network and cloud-synced paths can also be temporarily unavailable.
  • Values appear out of date: UpdateLinks:=0 intentionally skips external-link updates. Check whether the task needs refreshed links, and remember that formulas can also depend on the workbook’s calculation state.
  • Excel retains a lock or stays in memory: close the workbook when finished and, if using a separate application instance, quit that instance and release its object references. Do not quit the current Excel instance if the user is relying on it.

If a workbook is hidden and you need to inspect it, make its window visible again or close and reopen it visibly. Avoid ending the Excel process as a routine fix: that can lose unsaved work in other open workbooks.

Excel for Mac and Excel for the web

VBA is available in the desktop versions of Excel for Microsoft 365 on Windows and Mac, but the surrounding environment differs. File paths are different on Mac, and Windows COM automation for creating a separate Excel instance does not transfer to Mac. If using a hidden window on Mac, test the exact workbook and macro in the Mac desktop application rather than assuming every window-management detail behaves identically.

Excel for the web does not run VBA macros. A macro that opens and hides a workbook must be run in desktop Excel. The web version may display workbooks created or changed by desktop Excel, but it cannot execute this VBA procedure.

Frequently Asked Questions

Can VBA open a workbook without showing it at all?
It can hide the workbook window after opening, and disabling screen updating may reduce visible flicker. The standard Workbooks.Open call does not include a simple “never display” switch, so a brief display can depend on the environment. A separate hidden Excel instance is another option on Windows, with added complexity.

Does Application.ScreenUpdating = False hide the workbook?
No. It suppresses screen redraws while the macro runs; it does not set the workbook window’s visibility. Use the workbook window’s Visible property to hide the window, and restore screen updating afterward.

Can I read cells in a hidden workbook?
Yes. Hiding the window does not remove the workbook object or its worksheets. Refer to the workbook and sheet explicitly in VBA so your code does not accidentally use the active workbook instead.

How do I close a hidden workbook without saving?
Use wb.Close SaveChanges:=False with a reference to the workbook. This discards unsaved changes, so use it only when that is intended. If changes should be kept, save deliberately before closing.

Will a workbook’s macros run when VBA opens it?
They may, depending on Excel’s security settings and the way the file is opened. Hiding the workbook does not disable its macros. For programmatic opens, review Application.AutomationSecurity, restore any changed setting, and open only files you trust.

Related

Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.

More in VBA & macros

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.