VB6Load a Document
Public Function LoadDocument(ctldata As Variant)
   Dim p As New PropertyBag
   Dim pmdi As PrivateMDI
   p.Contents = ctldata
   Set pmdi = p.ReadProperty("EmbeddedControl")
   Set p = New PropertyBag
   ' Store current property set (without ctl GUID)
   pmdi.StoreProperties p
   ' Create a new control with this GUID
   Call CreateControl(pmdi.ProgId)
   ' We've actually created a second control here, 
   ' which will be placed
   Set pmdi = EmbeddedControl.object
   ' Load current property set (without ctl GUID)
   pmdi.LoadProperties p
End Function
Listing 5 The LoadDocument method creates a control from information stored in a file.