C++ COM add-in - find if MS Word, PPT, Excel has unsaved changes

166 views Asked by At

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++.

1

There are 1 answers

2
Eugene Astafiev On

An Office host Application instance is passed to the OnConnection method implemented in your code. Depending on the host you could use the Saved property, for example, in case of Word the Document class provides the Saved property which returns true if the specified document or template has not changed since it was last saved. False if Microsoft Word displays a prompt to save changes when the document is closed.

In case of Excel you can use the Workbook.Saved property which returns true if no changes have been made to the specified workbook since it was last saved.

In case of PowerPoint the Presentation.Saved property determines whether changes have been made to a presentation since it was last saved.