I think there are (at least) two different approaches:
1. It is possible to "embed" Microsoft Word (or other Office components) into your own application via ActiveX control. This way
your application kind of "remote controls" Word. But, clearly, this will require that Microsoft Word is installed on the system where your application is running. The user also will require a license for Microsoft Word, in addition to your application. On the pro side, all the gory details of reading or writing DOCX files will be "hidden" in Word and your application only needs to send to required commands.
https://www.codeproject.com/Articles/764/Using-MS-Office-in-an-MFC-Application
2. The other approach is to make your application read/write DOCX files
directly. This does
not require Microsoft Word to be installed at all. And it does
not require an Office license from Microsoft. But, of course, it will now be totally up to your application to parse/generate the DOCX files! In fact, the DOCX format is specified in the
Office Open XML (OOXML) standard, which is an "open" standard. So, in theory, it is totally possible to create your own DOCX parser/generator. After all, DOCX (and friends) are really just XML wrapped in a ZIP file. But, then again, Office Open XML has often been criticized to be extremely complex, so that only Microsoft can fully implement it... Unzipping and parsing the XML is only the very first step. Making sense of the data contained in the XML structure is the real challenge! 😏
https://en.wikipedia.org/wiki/Office_Open_XML
Using third-party libraries (e.g. "DuckX") for parsing and/or writing DOCX files may be an option to make approach (2)
much easier. But then you have to figure out whether the third-party library provides all the features (API) that you need, and whether the license of the third-party library is compatible with your project! For example, "DuckX" uses the MIT license, which is relatively liberal - good for you.
Does it really have to be DOCX, though? Most GUI frameworks (e.g. Qt) support some form of "rich text" documents out-of-the-box:
https://het.as.utexas.edu/HET/Software/html/richtext.html
https://het.as.utexas.edu/HET/Software/html/qtextdocument.html#details