HAL-9000
September 26th, 2001, 10:06 AM
Hi there,
I've got an OLE Container control on the main form of my VB App. I've also got a button control that I've written ( as an OCX). I've gotten the OLE container to create and display my button control via the "CreateEmbed" method, and I can then interface with the buttons via the "object" member of the OLE control. The OLE container is using late-binding to the button control, the project does not have any references to the button control ( because the implementation of the button control could change, or I might want to create a different button control via a different ProgID).
My problem is that at run-time I may want to unload the button control from the OLE container and then use a different ProgID to create a different kind of button control inside the OLE container. When I try to do this:
' OLE_Btn already contains a working button control
OLE_Btn.Close ' close existing button control
OLE_Btn.CreateEmbed "", "Btn.Btn" ' create new button
and then interface with the OLE_Btn.Object, it blows up with an error that says "Object variable or With block variable not set". As an experiment, I first create a Btn.Btn object, it worked fine, then tried to close it and create another Btn.Btn object, but it still blew up.
Am I supposed to use something other than the Close method? I tried the Delete method in OLE Container but that still produces the same error.
Thanks,
Aaron
"No representation is made that the information or opinions contained in this messages are greater than thoes provided by other messages."
I've got an OLE Container control on the main form of my VB App. I've also got a button control that I've written ( as an OCX). I've gotten the OLE container to create and display my button control via the "CreateEmbed" method, and I can then interface with the buttons via the "object" member of the OLE control. The OLE container is using late-binding to the button control, the project does not have any references to the button control ( because the implementation of the button control could change, or I might want to create a different button control via a different ProgID).
My problem is that at run-time I may want to unload the button control from the OLE container and then use a different ProgID to create a different kind of button control inside the OLE container. When I try to do this:
' OLE_Btn already contains a working button control
OLE_Btn.Close ' close existing button control
OLE_Btn.CreateEmbed "", "Btn.Btn" ' create new button
and then interface with the OLE_Btn.Object, it blows up with an error that says "Object variable or With block variable not set". As an experiment, I first create a Btn.Btn object, it worked fine, then tried to close it and create another Btn.Btn object, but it still blew up.
Am I supposed to use something other than the Close method? I tried the Delete method in OLE Container but that still produces the same error.
Thanks,
Aaron
"No representation is made that the information or opinions contained in this messages are greater than thoes provided by other messages."