如何/在何处使用 MS Project 2003 中的 VBA 保存持久数据
我目前正在使用 MS Project 2003 Visual Basic 编辑器编写宏,为此我需要保存 Excel 电子表格模板的路径。我希望用户能够更改路径并将设置永久保存在某处。
是否有一个方便的位置可以使用 VBA for MS Project 2003 保存持久数据?我想也许在 Global.mpt 的自定义字段中,但我不知道如何访问它。
I'm currently writing a macro using the MS Project 2003 Visual Basic editor, for which I need to save a path to an template excel spreadsheet. I'd like the user to be able to change the path and for the setting to be persistently saved somewhere.
Is there a convenient location to save persistent data using VBA for MS Project 2003? I was thinking perhaps in a custom field of Global.mpt, but I'm not sure how to access it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
VBA 有两个内置函数
GetSetting
和SaveSetting
,允许您简单、安全地将持久字符串数据保存到注册表。数据保存在 HKEY_CURRENT_USER 配置单元之外的文件夹中,因此数据是由用户保存的,而不是由机器保存的。有关详细信息,请参阅此处:使用 GetSetting 和 SaveSetting 函数读取和写入注册表设置
VBA has two built-in functions
GetSetting
andSaveSetting
that allow you to simply and safely save persistent string data to the registry. The data is saved in a folder off of the HKEY_CURRENT_USER hive, so the data is saved by user, not by machine.See here for details: Use the GetSetting and SaveSetting Functions to Read and Write Registry Settings
如果文件在另一个系统中使用,则使用注册表存储持久数据将不起作用。
您可以使用
CustomDocumentProperties
来存储您想要的任何值,它将与文件一起存储。Using Registry to store persistent data will not work if the file is used in another system.
You could use the
CustomDocumentProperties
to store any value you want and it'll be stored along with the file.