Name

Application.VBE

Synopsis

Returns the VBE object that represents the Visual Basic Editor. The following code displays the Visual Basic Editor:

Private Sub cmdViewCode_Click(  )
    On Error Resume Next
    Application.VBE.MainWindow.Visible = True
    ' An error occurs if security settings prohibit this.
    If Err Then
        MsgBox "You must change Macro security options " & _
          "before you can view code in this way. " & _
          "Choose Tools>Macro>Security>Trusted Publishers and " & _
          "select Trust access to Visual Basic Project."
    End If
End Sub

Get Programming Excel with VBA and .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.