Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In my Excel file, i have both a module and a class module. When i open VBA editor, the class module's code loads into the main window and if i want to see the module's code, i have to click on "+ Modules" folder and select my module.

How can i set up the editor to load the module's code on startup?

share|improve this question

Sorry, this is a work around as I have not found any options to do what you requested. The only way I know to get it to open the specific module you want is to open the Macro Window, choose the macro which is associated with the module you want opened, then click Edit.

Keyboard shortcut to open the Macro Window is Alt + F8. Then press E while still holding Alt to Edit the first macro.

enter image description here

share|improve this answer
Alt+F8+E shortcut will definitelly help (i edited the answer to include Alt+E to edit the first macro), if no better answer will come in a day, i'll accept this one :) – Aprillion Jun 27 '12 at 14:13

This doesn't answer your question, but it removes a step from the way you currently do it. Use the "Toggle Folders" button at the top of the Project Explorer, to list all VBA objects in alpha order instead of by type. It's the one under "VBA-Project" in the picture:

Toggle Folders button

Edit: One other thought is you could have code in the Workbook_Open or Workbook_Activate event that would shift the view to the Module. I think it would have limited utility, but might be worth trying something like this in the ThisWorkbook module:

Private Sub Workbook_WindowActivate(ByVal Wn As Window)
End Sub

Note that you have to go into the "Trust Center," choose "Trust Center Settings" and then "Macro Settings" and check "Trust access to the VBA project model" or you'll get a runtime error of "Programmatic Access to Visual Basic Project is not trusted."

share|improve this answer
i'll have to see which object will be open on startup, but it is a persistent setting, so +1 for saving at least 1 doubleclick in any case – Aprillion Jun 27 '12 at 18:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .