开发者

Should I use auto_open/close or workbook_open/beforeclose to run VBA on open?

In Excel 2003/2007, in which cases should I use auto_open/auto_close routines, and in which cases should I use the workbook_open/workbook_beforeclose events instead?

Apart from backward compatibility to prehistoric versions of 开发者_运维问答Excel, the difference I'm aware of is that one is public and one is private. What (if any) are the other differences?


I spent a long time once choosing between the opening variants of these, and we used Auto_Open. The main rationale was because if anyone runs the following code:

Application.EnableEvents = False

... then the Workbook_Open event will not fire. I had a feeling there was another situation where Workbook_Open didn't work either, but I can't remember it now.

I don't have a strong opinion about the close events, but to be honest I'd use the Auto_Close there too. At the end of the day, it's had more testing.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜