简体   繁体   English

无法访问 Excel VBA 代码

[英]Can't access Excel VBA Code

I have an Excel file with some VBA code.我有一个带有一些 VBA 代码的 Excel 文件。 That code also includes a Form that is displayed on auto_open() call.该代码还包括一个在 auto_open() 调用中显示的表单。

I never had problems opening VBA code form developers tab before.我以前从未在打开 VBA 代码表单开发人员选项卡时遇到问题。 But now when I open that file it automatically calls the auto_open() (the form is displayed) and I can't access the code anymore.但是现在当我打开该文件时,它会自动调用 auto_open() (显示表单)并且我无法再访问代码。 If I close the form the file is closed as well.如果我关闭表单,文件也会关闭。

This problem started when I shut down Excel from the task manager because the VBA code was hanging.当我从任务管理器关闭 Excel 时,这个问题就开始了,因为 VBA 代码挂了。 Since then I couldn't access the VBA for ANY other file containing forms loaded from auto_open().从那以后,我无法访问包含从 auto_open() 加载的表单的任何其他文件的 VBA。

NOTE: I already tried opening the file with the Shift key hold.注意:我已经尝试过按住 Shift 键打开文件。

What is the problem?问题是什么? How can I access to the VBA macros as I used to do?如何像以前一样访问 VBA 宏?

Thanks Miguel谢谢米格尔

Here's the way I managed this:这是我管理这个的方式:

Rather than double-clicking the file in Windows I did:我没有在 Windows 中双击文件:

  1. Opened Excel打开 Excel
  2. File -> Open文件 -> 打开
  3. Browsed the file and hold the "shift" key while clicking on "Open".浏览文件并在单击“打开”时按住“shift”键。 (continue holding it until the workbook finishes loading) (继续按住它直到工作簿完成加载)

Pressing shift and break key, should open up the code and then you can click the stop button and edit as you like.按 shift 和 break 键,应该打开代码,然后您可以单击停止按钮并根据需要进行编辑。 This has worked for me several times where I have auto_open method with a user form.这对我有用过几次,我有一个带有用户表单的 auto_open 方法。 The other alternative would be to change the trust settings to always ask, that would stop any macro running.另一种选择是将信任设置更改为始终询问,这将停止任何宏运行。 You could then access code in usual way.然后您可以以通常的方式访问代码。

My situation was all of the procedures appeared on different sheets, no matter what I did I could not bring them over to one sheet.我的情况是所有的程序都出现在不同的工作表上,无论我做什么,我都无法将它们放在一张纸上。 I studied the screen and my solution is as follows.我研究了屏幕,我的解决方案如下。

SOLUTION FOR PROCEDURES BEING ON DIFFERENT SHEETS: In the lower left corner of the code sheet you will see two icons with lines.不同工作表上程序的解决方案:在代码表的左下角,您将看到两个带线条的图标。 One is for " Procedure " view and the other is for " Full Module " view.一种用于“过程”视图,另一种用于“完整模块”视图。

I always use the "Full Module" view but at some point I clicked "procedure".我总是使用“完整模块”视图,但在某些时候我单击了“程序”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM