You have created an "unqualified" reference to an Excel application that you cannot release by utilizing a Global variable intended for VBA that should not be used in VB 6.0.
This is an unfortunate side-effect of using VB 6.0, but it is the only problem I know of using VB6, and it is easily fixed.
The problem in your case stems from using the 'ActiveSheet' global variable. When using VBA, this is fine, but when using VB 6.0, you must avoid this or else you create an Excel application that you cannot release. This approach will run fine the first time, but will cause all kinds of undefined behavior the second time your routine runs.
In your example, the code should do something like this:
Sub Macro1()
Dim xlApp As Excel.Application
Set xlApp = New Excel.Application
xlApp.ActiveSheet.OLEObjects.Add(ClassType:="test.test_control.1" _
, Link:=False, DisplayAsIcon:=False).Select
' Then when done:
xlApp.Quit()
xlApp = Nothing
End Sub
For a detailed discussion about how to handle this in general, see:
VB 6.0 Tutorial - Finding and Repairing Unqualified References
(http://www.xtremevbtalk.com/showthread.php?p=900556#post900556)
For Microsoft documentation on this issue see:
Excel Automation Fails Second Time Code Runs (MSKB 178510)
(http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/q178/5/10.asp)
Error or Unexpected Behavior with Office Automation When You Use Early Binding in Visual Basic (MSKB 319832)
(http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q319832&)
Edit: Note that using html 'a' tags were not working with these links for some reason. Someone might need to look into the parser?
Best Answer
ActiveX would allow you to define your own methods on your own interface (to address Brians assumption), but that likely won't help here. The ActiveX control might very well be created by another component. ATL too is irrelevant - it's a C++ template library that wraps COM interfaces.
The function you need here is IOleWindow::GetWindow. I'm not sure what you mean by "override an ATL function to use the HWMD". Once you have retrieved the HWND, you can pass it to any function that uses an HWND. For instance, as the parent in SetParent(child, parent)