You should review the object models for each of Excel, Word and PowerPoint. If you look carefully you will see that the Excel workbook object, the Word document object and the PowerPoint presentation object each have a Saved property which will give you the information you want.
C++ COM add-in - find if MS Word, PPT, Excel has unsaved changes

I have created a basic COM add-in for MS office apps like Word, PPT, Excel in Visual C++ using _IDTExtensibility2 interface.
Now i want my add-in to find if Word, PPT, Excel has any unsaved changes.
FYI: I have not chosen VSTO or Office JS add-in due to dependency/deployment reasons.
Kindly provide solution in C++.
2 answers
Sort by: Most helpful
-
-
RLWA32 32,146 Reputation points
2022-04-08T12:00:36.667+00:00 Maybe it is too early to call get_activedocument() method as during onConnection the document is yet to be created. But i don't know how/where to call get_activedocument() method once document is created.
Yes, that's a problem. Since I previously provided you a sample Add-in for a TaskPane I updated the sample to provide some minimal functionality. All the previous comments about how it was created are still in effect. The updated sample can create a TaskPane in Excel and Word. The ActiveX control hosted by the TaskPane now includes two items - an edit control that identifies which Office application it is loaded into and a button that checks the Saved property.
For Excel -
and
For Word -
and
The updated Add-In can be obtained at s!AmnqrCFBv4nDgiLKcnfX4cf0S2a0