I've done this task by creating a VB6 COM dll to handle this task.
Option Explicit
Dim objMyPropertyBag As PropertyBag
Public Sub Contents(a_content As Variant)
objMyPropertyBag.Contents = a_content
End Sub
Public Function Read(key As String) As String
On Error GoTo Error_Handler
Read = objMyPropertyBag.ReadProperty(key)
Error_Handler:
MsgBox Err.Source & Err.Number
End Function
Private Sub Class_Initialize()
Set objMyPropertyBag = New PropertyBag
End Sub
When I open the my old Excel workbook which contains an old ActiveX object. I do the following steps:
- It will come to IPersistStreamInit::Load function which give me an IStream.
- I read this stream and parse to VARIANT of SAFEARRAY of VT_UI1 (equal to array of BYTE) called "content".
- I create an instance of VB6 COM dll, called "contentReader".
- I call contentReader->Contents(content) (pass the SAFEARRAY I've created to it).
Now I can read any key in the PropertyBag via contentReader->Read([in] key, [out] value).