I’m trying to automatically display the IDE when Excel is launched.
Is there a way to simulate a click on the “Visual Basic Editor” icon in the ribbon? I looked into
Application.CommandBars but there’s nothing about the Ribbon.
Private Sub Workbook_Open() ' Display Visual Basic Editor End Sub
Commandbars object has an
ExecuteMso method that allows you to “push” any Ribbon button, so:
As noted by Comintern, the
Application qualification is necessary when using this in a
Workbook_Open event, otherwise you’ll get an error 91.
To find the mso, go into the Quick Access toolbar’s Ribbon menu, find what you want and hover:
It would be
Private Sub Workbook_Open() ' Display Visual Basic Editor Application.VBE.MainWindow.Visible = True End Sub
If you get Programmatic Access error:
Programmatic Access To Visual Basic Project Is Not Trusted – Excel