Is there a way to automatically go to code view (alt-f11) immediately upon opening workbook/sheet?

88 Views Asked by At

Want to bypass worksheet open as well as bypass userform object, and I don't want to execute userform code, I simply want to immediately go directly to the code view of a specific userform. Anyone know a way?

Explored internet and tried creating a macro but to no avail. Near I can get is ALT-F11 but it does not take you immediately to a userform code. Have to scroll a long list of forms to get to its code. This is what I'm trying to avoid. When you are developing code, the steps to get to the code multiple times could be lessened considerably if this quick path was available or existed. Tie the code and object to a single toggle button? Also open to vs or other executable that will accomplish same.

1

There are 1 best solutions below

2
ΑΓΡΙΑ ΠΕΣΤΡΟΦΑ On

Office 2019

Private Sub Workbook_Open()
   Application.CommandBars.ExecuteMso "VisualBasic"
End Sub

I don't know of any way that programmatically takes you (automatically) to the code of the form after you define its name parametrically. But if there was such a possibility, then on opening it would always take you to the code of the same form. If you wanted something else the next time you opened it, you had to change the name of the form in the assumed code. In short, you should know the name of the form or are you only interested in the form you are currently working on? For both, do the following: In the code of the form, put its name as a comment, e.g. '@@@myform, and in the one you are working on, put another comment '@@@###

When the VB window opens in any module, search either @@@myform or @@@### to go directly to where you want.