数据结构快照,VBA excel [英] Snapshot of data structures, VBA excel

查看:201
本文介绍了数据结构快照,VBA excel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:


是否可以在VBA Excel中执行所有使用的模块和数据结构的快照,并在一段时间后恢复? p>

原因是在崩溃后复制错误



ADDED。是的,本质上我想序列化类和类型。

解决方案


我觉得你的样子想要将所有的类序列化为
,它们是一个XML文件?我知道这个函数存在于其他
语言中,但VBA可能没有它。 (我确定你可以
强制某些东西) - Brad



@Brad,是的,正如一种可能的方式 - nikaan


假设VBA不存在此方法(尽管它可用于VB.NET或VB 2005: http://support.microsoft.com/kb/315703 ),我可能会尝试做一个模拟:写入每个对象的状态/通过使用FSO,txt文件中的变量(需要的)。

我不知道这是否适合您的项目,而且我可能不愿意为此而付出巨大的代价的代码。

  dim sFile As string 
Dim FSO As FileSystemObject
Dim FSOFile As TextStream


sFile =U:/Log.txt

设置FSO =新建FileSystemObject
设置FSOFile = FSO.OpenTextFile(sFile,2,True)
FSOFile.writeline(<描述+属性/变量值>)
FSOFile.Close
设置FSO =无

根据您输入描述的方式(例如,为成功实例化对象而引用布尔值等),您可能可以看到屏幕后面发生了什么,直到你的应用程序崩溃...
我不知道这是否回答你的问题,因为我有点怀疑你所提及的领域(评论)。


Possible Duplicate:
What's the fastest way to export all excel add-in modules to .bas files?

Is it possible to do snapshot of all used modules and data structures in VBA Excel and recover it some time after?

The reason is reproducing error after crashes

ADDED. Yes, in essence I want to serialize classes and types.

解决方案

I feel like what you kind of want is to serialize all your classes as they are to an XML file? I know this function exists in other languages but VBA might not have it as it is. (I'm sure you could force something) – Brad

@Brad, yes, exactly, as one of possible ways – nikaan

Assuming that this method does not exist for VBA (although it is available for VB.NET or VB 2005: http://support.microsoft.com/kb/315703), I would probably try to make a simulation: Write the state of each object / variable (of those needed) to a txt file by using FSO.
I don't know if this is feasible for your project though and I probably wouldn't like to do this with pleasure for a huge amount of code.

dim sFile               As string 
Dim FSO                 As FileSystemObject     
Dim FSOFile             As TextStream 


sFile = "U:/Log.txt"

Set FSO = New FileSystemObject
Set FSOFile = FSO.OpenTextFile(sFile, 2, True) 
FSOFile.writeline (<Descriptions+Property/variable value>) 
FSOFile.Close
set FSO = nothing 

Depending on how well you input descriptions (eg. inlcuding boolean values for successful instantiation of objects, etc...), you may be able to see what has happened behind the screen up to the point where your application crashed... I don't know if this answers your question, as I'm a little bit doubting about what you refer to with "fields" (comments).

这篇关于数据结构快照,VBA excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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