2

I built some custom VBA objects and I would love to be able to save them in my hard drive as they are, so not put them in a database. Can't figure out how to do that.

Just to make my point clear, the code I have in mind would look like something like this:

dim MyObject as MyObjectClass
Set MyObject = new MyObjectClass

MyObject.Whatever = whatever
MyObject.SaveAs (path)

Any clues?

Alex K.
  • 171,639
  • 30
  • 264
  • 288
  • **What is it that you want to save?** Object instance? properties? save all properties of an object that has been created during runtime in the memory to a txt file? you have to be more specific, describe where you are going with it –  Jul 19 '13 at 09:56
  • @mehow. Indeed good question! The thing is my objects contain dictionaries that contain other custom objects, in a chain. So I guess the answer would be the instances? I guess I could save the lowest level object properties and when I load it (something like: Set MyOject = LoadObject(path)) I could rebuild it all the way to the highest level. I was hoping there would be some built-in easier way to do it. –  Jul 19 '13 at 12:01
  • 1
    You would have to do it manually yourself, there doesn't exist build-in object serializer in VBA I am afraid. So just write the code of SaveAs() method which will save the content of your object-tree to XML. And LoadObject() method will then restore the object-tree into the memory from saved XML. – Daniel Dušek Jul 19 '13 at 13:59
  • Tks Daniel Dusek. Will start with 'XML wiki":-). –  Jul 19 '13 at 15:56

0 Answers0