H
Hemilton Chen
Hi,
We encounter the following problem with either Office applications or APIs.
Please advise us if it is product defect and if there is any alternative or
workaround to achieve what we are trying to do. Thanks.
Description:
When a document contains link objects and is dirty, Word always prompts for
save during document close although we have set through API that it’s already
saved (or use Close API with VARIANT_FALSE for 1st parameter). In our
application, we listen to OnDocumentClose event and prompt user to save when
necessary. If user chooses NO, we will need to close the document silently
without save.
Brief steps to re-produce:
1, Create a Word 2007 COM Add-in using ATL with Ribbon
UI(I am trying to upload a test app, but i can't find any approaches in this
newsgroups site)
2, Hook the DocumentBeforeClose event and add the following
codes in it.(see the code snippet at the end of this posting)
3, Register the COM dll via regsvr32 command and make sure it's
registered successfully.
4. Start Word 2007 with the above COM Add-in and insert a link object(Excel
or PPT file)
5. Close the document
Result: Word prompts for save
Expected behavior: Word shouldn’t prompt for save
void __stdcall CAddin:ocumentBeforeClose(IDispatch* /*Document**/ ptr,
VARIANT_BOOL * Cancel )
{
CComQIPtr<_Document> spDoc(ptr);
HRESULT hr = spDoc->put_Saved(VARIANT_TRUE);
ATLASSERT(SUCCEEDED(hr));
}
We encounter the following problem with either Office applications or APIs.
Please advise us if it is product defect and if there is any alternative or
workaround to achieve what we are trying to do. Thanks.
Description:
When a document contains link objects and is dirty, Word always prompts for
save during document close although we have set through API that it’s already
saved (or use Close API with VARIANT_FALSE for 1st parameter). In our
application, we listen to OnDocumentClose event and prompt user to save when
necessary. If user chooses NO, we will need to close the document silently
without save.
Brief steps to re-produce:
1, Create a Word 2007 COM Add-in using ATL with Ribbon
UI(I am trying to upload a test app, but i can't find any approaches in this
newsgroups site)
2, Hook the DocumentBeforeClose event and add the following
codes in it.(see the code snippet at the end of this posting)
3, Register the COM dll via regsvr32 command and make sure it's
registered successfully.
4. Start Word 2007 with the above COM Add-in and insert a link object(Excel
or PPT file)
5. Close the document
Result: Word prompts for save
Expected behavior: Word shouldn’t prompt for save
void __stdcall CAddin:ocumentBeforeClose(IDispatch* /*Document**/ ptr,
VARIANT_BOOL * Cancel )
{
CComQIPtr<_Document> spDoc(ptr);
HRESULT hr = spDoc->put_Saved(VARIANT_TRUE);
ATLASSERT(SUCCEEDED(hr));
}