从VBA打开一个工作簿并禁用Workbook_Open()代码? [英] Open a workbook from VBA and disable Workbook_Open() code?

查看:454
本文介绍了从VBA打开一个工作簿并禁用Workbook_Open()代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用VBA打开电子表格,并且一些工作簿包含在调用Workbook_Open()时开始执行的代码。



如何使用VBA打开工作簿但是停止代码自动执行?我只打开工作簿来查看表格中的公式 - 我不想执行任何代码。

解决方案

要在VBA中打开工作簿之前尝试禁用事件,然后在模块的其余部分重新启用它们?尝试使用这样的东西:

  Application.EnableEvents = False'disable Events 
workbooks.OpenWORKBOOKPATH'open工作簿
Application.EnableEvents = True'启用事件


I am opening spreadsheets using VBA and a couple of the workbooks contain code which starts executing when Workbook_Open() is called.

How can I open the workbooks using VBA but stop the code automatically executing? I am only opening the workbooks to look at formulae in the sheet- I do not want any code execution.

解决方案

Would you like to try disabling the Events before you open the workbook in VBA and then re-enabling them for the rest of the module? Try using something like this:

Application.EnableEvents = False   'disable Events
workbooks.Open "WORKBOOKPATH"      'open workbook in question
Application.EnableEvents = True    'enable Events

这篇关于从VBA打开一个工作簿并禁用Workbook_Open()代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆