PRB: ATL Control Properties Do Not Persist when Embedded in Word (241936)
The information in this article applies to:
- Microsoft Word 2002
- Microsoft Word 2000
- Microsoft Word 97 for Windows
- The Microsoft Active Template Library (ATL) 3.0
This article was previously published under Q241936 SYMPTOMS
Microsoft Word does not appear to save the properties of an Active Template Library (ATL) ActiveX control when the document is saved and then re-opened. Trace statements in ATL show that IPersistStorage and IPersistStreamInit are being called to both save and load the control's settings, but the control appears to be initialized to a new state every time the document is opened.
CAUSE
The problem occurs because ATL's implementation of IPersistStreamInit::Save and IPersistStreamInit::Load performs a QueryInterface call to get the IDispatch of the root control from which it will persist stock properties. Because Word wraps all embedded controls in an aggregated extender object, the QueryInterface call is returning the IDispatch of the Word extender and not the internal control. This causes the persist methods to fail when saving and loading the control in certain circumstances.
RESOLUTION
To resolve the problem, you need to overwrite the IPersistStreamInit_Load and IPersistStreamInit_Save functions for your control, and create modified versions of the global functions AtlIPersistStreamInit_Load and AtlIPersistStreamInit_Save. See the sample below for the steps to needed to resolve the issue.
REFERENCES
For additional information on ATL controls in Office, please click the article numbers below
to view the articles in the Microsoft Knowledge Base:
214462 PRB: Error "Bound to unknown type" Inserting ATL Control in VBA 197490 PRB: ATL Full Control Needs Enabled Stock Property for Access 97
Modification Type: | Major | Last Reviewed: | 12/15/2003 |
---|
Keywords: | kbCtrlCreate kbprb KB241936 |
---|
|