excelvbapanevbe

How to disabe the "Project - VBA Project" pane?


This macro will hide/close the VBE Main Window:

Sub VBEMainWindowHide()
    'close VBE window:
    Application.VBE.Window.Visible = False
End Sub

I am attempting to close or hide the "Project - VBA Project" Pane. This pane displays all the Sheets in the workbook, the ThisWorkbook Module, etc.

I tried Application.VBE.Projects.Visible = False, Application.VBE.("Projects - VBA Project") and one or two other combinations using the same terms.


Solution

  • You can use Application.VBE.Windows("WindowName").Close to close the relevant VBE Window.

    See this

    Option Explicit
    
    Sub Sample()
        Dim i As Long
        For i = 1 To Application.VBE.Windows.Count
            Debug.Print Application.VBE.Windows(i).Caption
        Next i
    End Sub
    

    This will give you something like this in the Immediate Window

    Module1 (Code)
    Book1 - Sheet1 (Code)
    Project - VBAProject
    
    Properties - Module1
    Object Browser
    Watches
    Locals
    Immediate
    

    So

    Application.VBE.Windows("Immediate").Close 
    

    will close the Immediate window. Similarly to answer your question

    Application.VBE.Windows("Project - VBAProject").Close 
    

    will close the "Project - VBA Project" pane. And to show it again, you can use

    Application.VBE.Windows("Project - VBAProject").Visible = True