Excel关闭时存储变量 [英] Store Variable While Excel is Closed

查看:72
本文介绍了Excel关闭时存储变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在Excel关闭时存储变量,然后在Excel打开时将其读回。 我有一个Auto_Close宏,它将变量的值写入单元格,然后保存文件。 我有一个Auto_Open宏,它将变量设置为同一个单元格的
值。 如果我对变量进行监视并逐步执行Auto_Open宏,它似乎可以正常工作。

I have a need to store a variable when Excel closes, then read it back in when Excel opens.  I have an Auto_Close macro that writes the value of variable to a cell and then saves the file.  I have an Auto_Open macro that sets the variable to the value of that same cell.  If I put a watch on the variable and step through the Auto_Open macro, it seems to work.

但是,我发现Auto_Open后其他宏无法使用该值宏完成。 我认为这是变量尺寸方式的问题,或者我需要每次
a宏需要时从单元格中读取值,并在每次更改时将新值写入单元格。

However, I am finding that the value is not available to other macros once the Auto_Open macro completes.  I am thinking that either this is a problem with the way the variable is dimensioned, or I need to read the value from the cell each time a macro needs it, and write the new value to the cell each time it changes.

最好的方法是什么? 有没有办法将变量保留在内存中,即使没有宏运行,或者我是否需要每次都写入并读取它?

What is the best way to do this?  Is there a way to keep the variable in memory even when no macros are running, or do I need to write it and read it every time?

- Tom

推荐答案

您好thomasm516,



您能否提供保存和读取变量的代码?

如果是Auto_Open或Auto_Close,请指定打开或关闭的目标。



问候,
Hi thomasm516,

Could you provide the code that saves and read a variable?
If it is Auto_Open or Auto_Close, please specify its target for opening or closing.

Regards,


这篇关于Excel关闭时存储变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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