question

yanpeng avatar image
0 Votes"
yanpeng asked yanpeng commented

How to create a task pane in Office using pure C++/COM?

I am very interested in the technology behind office add-ins. I have learned a little about its history, and know about several technologies that can be used to develop add-ins.
1. Office.js
2. VSTO
3. COM Shim
4. COM

I don't have good knowledge of Shim, maybe I am wrong in making it a separate category. After getting the book on VSTO(the book was published in 2007), I tried how to develop an office add-in using VSTO. I also do some extra development, such as embedding the Chromium kernel, so that I can load web pages using Chromium, instead of the IE kernel(it doesn't have good support on the new web standards).

What makes me sad is that, for using VSTO, I have to install the new two libraries, one is the .net framework, and the other is vstor(vsto runtime). On some machines, I cannot install these libraries successfully, so I prepare to develop office add-ins(in my case, the Word add-in) using C++/COM. (I guess Office was constructed using COM, we can use pure C++ to develop an add-in not depending on other libraries.)

But the really hard part is that COM technology is not popular now (sorry for what is popular) and the method of how to develop office add-ins using COM is even lost! I cannot search for any useful information on this topic on the Microsoft website.

Everything needs a start, my aim is to create a task pane(I need this to load web pages later) using C++/COM, but now, I don't how to achieve this, so I ask this question here, wishing to get some help.





c++office-addins-devoffice-vsto-com-dev
· 12
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Put Task Panes aside for now. First you need to become familiar with the basic mechanics of Office Add-ins written in unmanaged C++ using COM.

There is an old Microsoft sample that you can retrieve from Outlook 2010: Building a C++ Add-In. This should give you a starting point. How familiar are you with COM? Have you ever used ATL? Have you ever used COM from an application to automate an Office application?


0 Votes 0 ·

No, I never use COM directly to develop Office-related applications. Recently, in order to complete this goal, I searched some web pages, ready to download the following books:
1. Inside COM by Dale Rogerson
2. Essential COM by Don Box
3. Developer's Workshop to COM and ATL 3.0 by Andrew Troelsen
4. ATL Internals Working with ATL 8 by Christopher Tavares, Kirk Fertitta
5. Understanding COM+
6. Understanding DCOM
7. Sams Teach Yourself ATL Programming
8. Essential IDL - Interface Design for COM by Martin Gudgin
9. COM IDL and Interface Design by Dr. Al Major
10. Designing and using ActiveX Controls by Tom Armstrong
11. Inside OLE by Kraig Brockschmidt
12. Beginning ATL 3 COM Programming Richard Grimes
13. Professional ATL COM Programming by Richard Grimes
14. Windows via C/C++
15. Programming Windows
I don't know if these books are enough to help me develop Office COM Add-Ins. The experience I just deal directly with COM is using DirectX.

0 Votes 0 ·

That is quite a reading list. You don't need to read all of them to learn COM fundamentals. I have "Inside Ole 2nd Edition" by Kraig Brockschmidt and "Inside ATL" by George Shepherd and Brad King in my library. I may add "Essential COM" by Don Box.

Since your experience with COM seems to be limited I suggest you start slow and learn the fundamentals. The ATL framework does a wonderful job of simplifying COM development because it provides the scaffolding which can be used to speed implementation. It is a powerful tool. However, for someone just starting out the framework support obscures what is going on under the hood and behind the scenes.

As far as COM and Office applications go, you should understand the IDispatch interface, dual interfaces, threading models, in-process vs. out-of-process servers and how to use type libraries. Of course that's not an all-inclusive list. Browsing Office application type libraries using the Windows SDK utility oleview.exe can be very helpful when writing add-ins or code that automates an Office application. It is also essential to understand the object model of the Office applications with which you intend to interact. This understanding can be obtained by reading Microsoft's object model documentation written for VBA or .Net.

Before you plunge into add-ins I suggest you write a few simple COM Servers and related client applications to get the feel of how the technology works.

0 Votes 0 ·
Show more comments

And for general COM knowledge there is always Microsoft's own documentation.

https://docs.microsoft.com/en-us/windows/win32/com/com-fundamentals


0 Votes 0 ·

As your issue is more related to Office developement, I would suggest you post new threads on following forums.
Word add-ins developer community
Excel add-ins developer community
PowerPoint add-ins developer community
Thanks for your understandings.

0 Votes 0 ·
yanpeng avatar image yanpeng MinxinYu-MSFT ·

Thanks, I'll post the next question on the relevant forum.

0 Votes 0 ·

1 Answer

Bruce-SqlWork avatar image
0 Votes"
Bruce-SqlWork answered yanpeng commented

com addins are only for legacy office applications. Also they are only supported for the desktop windows versions. Though I would not be surprised if even this support is dropped.

As the cloud became more important, a new plug-in architecture was developed for office. Now plug-ins are developed with html/css and JavaScript. The actual exchange server can serve as the installer (store) , and they work cross platform.

https://docs.microsoft.com/en-us/office/dev/add-ins/develop/develop-overview

The Office team supplies react components for all the office style controls, and matching css for office look. If you pick another framework besides react, they have a standalone sass/css package. The office team tends to use react for the official plug-ins so they are a good choice. You just need node installed to develop.

React fabric ui (sample code builds task pane)

https://docs.microsoft.com/en-us/office/dev/add-ins/design/using-office-ui-fabric-react

Fabric ui sass

https://docs.microsoft.com/en-us/office/dev/add-ins/design/fabric-core

Not sure why you would invest time learning an obsolete technology. The time it takes to learn to write a simple com component (office add-ins require discovery also be coded), you could probably code the complete plug-in modern style.




· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Using COM to develop Office add-ins is indeed not the mainstream today, and there is a lack of materials, and the development is also difficult. For me, it's not a big problem that it only supports desktop systems, because in my case, even if I use office.js to develop add-ins, it is still only used on the desktop. In my place, most people don't have access to Office Online.

I want to choose COM for the following reasons.
1. Office.js only uses the system's built-in browser kernel, I can't switch it to Chromium (at least on Win7, Win10), using COM can load the dynamic link library of Chromium at startup, so that when rendering web pages, you can render with Chromium.
2. Many people are still using Office 2007, Office 2010, these versions cannot use add-ins developed by Office.js
3. For the above Office versions, if you use VSTO, additional dependencies (.net & vstor) will be generated, and some users fail to install these dependencies.
4. In my place, there is alternative software for Office, that is WPS, which has always been a competitor of Office. Many people use this software to replace Office(Office : WPS $\approx$ 6 : 4). This software is much more powerful than LibreOffice, and it can completely replace Office. This software also doesn't support office.js, but it can run add-ins developed with COM and VSTO.

Once you have an add-in that works on most office versions (in my case, Word), you can get the content of the Word document, which in turn can be combined with natural language processing, and communicate with remote services.

0 Votes 0 ·

Whether you use managed code or unmanaged C++/COM for your add-in you should know that your add-in will be responsible for creating and managing Task Panes in the Office application. For example, opening multiple existing workbooks in Excel or multiple existing documents in Word. Your add-in will also need to manage Task Panes for new items such as a new workbook or a new document. This is a non-trivial task.

0 Votes 0 ·

Yes, what you just said is exactly a mistake I made in the past. I'm actually sharing the task pane between multiple documents, which is obviously a problem. When opening a new document, what you see to the right of the new document is the contents of the previous document's task pane. I've left that company and this bug has not been fixed yet :( When developing future add-ins, I'll be careful to manage task panes for multiple documents.

0 Votes 0 ·