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

huangapple go评论76阅读模式
英文:

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

问题

I 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.

在互联网上探索过并尝试创建宏,但毫无结果。最接近的方法是ALT-F11,但它不会立即带您进入用户表单代码。 必须滚动长列表才能进入其代码。 这是我试图避免的情况。 当您开发代码时,如果存在或已经存在这种快速路径,多次进入代码的步骤可能会大大减少。 将代码和对象绑定到单个切换按钮? 还可以打开vs或其他可执行文件以实现相同的目标。

英文:

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

得分: 2

Office 2019

私有子程序 Workbook_Open()
   Application.CommandBars.ExecuteMso "VisualBasic"
End Sub

我不知道有什么办法可以通过编程的方式(自动地)将您带到在您以参数方式定义其名称后的表单代码中。但如果有这样的可能性,那么在打开它时,它总是会带您到相同表单的代码。如果您希望下一次打开时出现其他情况,您必须在假定的代码中更改表单的名称。简而言之,您应该知道表单的名称,或者您只对您当前正在处理的表单感兴趣吗?对于两者,按照以下步骤操作:在表单的代码中,将其名称作为注释,例如 '@@@myform,并在您正在处理的代码中,放置另一个注释'@@@###。

当VB窗口在任何模块中打开时,搜索 @@@myform 或 @@@### 以直接转到您想要的位置。

英文:

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.

huangapple
  • 本文由 发表于 2023年5月17日 21:25:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/76272616.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定