IRibbonExtensibility in unmanaged C++

M

Mark Wilson

I have an unmanaged C++ COM addin that works with Office XP and Office 2003.
I'd like to add support for the Ribbon UI for those situations when the addin
is installed on Office 2007. I've used VSTO 2005 SE to build a C# addin that
puts a simple button on the Ribbon. However, I currently don’t develop in C#
and don't want to have to convert a lot of existing code to C#. I also don't
necessarily want mscoree.dll as the DLL that loads my application.

So my question is can Ribbon support be added to an unmanaged C++ COM Addin,
or is there something in .NET that the Ribbon depends upon and it will just
not work in any other context?
 
M

Mark Wilson

Thanks Patrick.

So if I'm going to compile and link this C++ addin I'll need a header file
to #include and some .LIB file to link with.

For example where is something like RequestService or GetCustomUI defined?
--
Mark Wilson



Patrick Schmid said:
Unmanaged C++ should work.

Patrick Schmid [OneNote MVP]
--------------
http://pschmid.net
***
Office 2007 RTM Issues: http://pschmid.net/blog/2006/11/13/80
Office 2007 Beta 2 Technical Refresh (B2TR):
http://pschmid.net/blog/2006/09/18/43
***
Customize Office 2007: http://pschmid.net/office2007/customize
OneNote 2007: http://pschmid.net/office2007/onenote
***
Subscribe to my Office 2007 blog: http://pschmid.net/blog/feed

I have an unmanaged C++ COM addin that works with Office XP and Office 2003.
I'd like to add support for the Ribbon UI for those situations when the addin
is installed on Office 2007. I've used VSTO 2005 SE to build a C# addin that
puts a simple button on the Ribbon. However, I currently don't develop in C#
and don't want to have to convert a lot of existing code to C#. I also don't
necessarily want mscoree.dll as the DLL that loads my application.

So my question is can Ribbon support be added to an unmanaged C++ COM Addin,
or is there something in .NET that the Ribbon depends upon and it will just
not work in any other context?
 
P

Patrick Schmid [MVP]

I suggest you read
http://msdn2.microsoft.com/en-us/aa338202(office.12).aspx
http://msdn2.microsoft.com/en-us/aa338199(office.12).aspx
http://msdn2.microsoft.com/en-us/aa722523(office.12).aspx

Patrick Schmid [OneNote MVP]
--------------
http://pschmid.net
***
Office 2007 RTM Issues: http://pschmid.net/blog/2006/11/13/80
Office 2007 Beta 2 Technical Refresh (B2TR):
http://pschmid.net/blog/2006/09/18/43
***
Customize Office 2007: http://pschmid.net/office2007/customize
OneNote 2007: http://pschmid.net/office2007/onenote
***
Subscribe to my Office 2007 blog: http://pschmid.net/blog/feed

Thanks Patrick.

So if I'm going to compile and link this C++ addin I'll need a header file
to #include and some .LIB file to link with.

For example where is something like RequestService or GetCustomUI defined?
--
Mark Wilson



Patrick Schmid said:
Unmanaged C++ should work.

Patrick Schmid [OneNote MVP]
--------------
http://pschmid.net
***
Office 2007 RTM Issues: http://pschmid.net/blog/2006/11/13/80
Office 2007 Beta 2 Technical Refresh (B2TR):
http://pschmid.net/blog/2006/09/18/43
***
Customize Office 2007: http://pschmid.net/office2007/customize
OneNote 2007: http://pschmid.net/office2007/onenote
***
Subscribe to my Office 2007 blog: http://pschmid.net/blog/feed

I have an unmanaged C++ COM addin that works with Office XP and Office 2003.
I'd like to add support for the Ribbon UI for those situations when the addin
is installed on Office 2007. I've used VSTO 2005 SE to build a C# addin that
puts a simple button on the Ribbon. However, I currently don't develop in C#
and don't want to have to convert a lot of existing code to C#. I also don't
necessarily want mscoree.dll as the DLL that loads my application.

So my question is can Ribbon support be added to an unmanaged C++ COM Addin,
or is there something in .NET that the Ribbon depends upon and it will just
not work in any other context?
 
M

Mark Wilson

Thanks. I had read 1/3 and 2/3 but could never find the third article.

I'll give it a read.

--
Mark Wilson



Patrick Schmid said:
I suggest you read
http://msdn2.microsoft.com/en-us/aa338202(office.12).aspx
http://msdn2.microsoft.com/en-us/aa338199(office.12).aspx
http://msdn2.microsoft.com/en-us/aa722523(office.12).aspx

Patrick Schmid [OneNote MVP]
--------------
http://pschmid.net
***
Office 2007 RTM Issues: http://pschmid.net/blog/2006/11/13/80
Office 2007 Beta 2 Technical Refresh (B2TR):
http://pschmid.net/blog/2006/09/18/43
***
Customize Office 2007: http://pschmid.net/office2007/customize
OneNote 2007: http://pschmid.net/office2007/onenote
***
Subscribe to my Office 2007 blog: http://pschmid.net/blog/feed

Thanks Patrick.

So if I'm going to compile and link this C++ addin I'll need a header file
to #include and some .LIB file to link with.

For example where is something like RequestService or GetCustomUI defined?
--
Mark Wilson



Patrick Schmid said:
Unmanaged C++ should work.

Patrick Schmid [OneNote MVP]
--------------
http://pschmid.net
***
Office 2007 RTM Issues: http://pschmid.net/blog/2006/11/13/80
Office 2007 Beta 2 Technical Refresh (B2TR):
http://pschmid.net/blog/2006/09/18/43
***
Customize Office 2007: http://pschmid.net/office2007/customize
OneNote 2007: http://pschmid.net/office2007/onenote
***
Subscribe to my Office 2007 blog: http://pschmid.net/blog/feed


I have an unmanaged C++ COM addin that works with Office XP and Office 2003.
I'd like to add support for the Ribbon UI for those situations when the addin
is installed on Office 2007. I've used VSTO 2005 SE to build a C# addin that
puts a simple button on the Ribbon. However, I currently don't develop in C#
and don't want to have to convert a lot of existing code to C#. I also don't
necessarily want mscoree.dll as the DLL that loads my application.

So my question is can Ribbon support be added to an unmanaged C++ COM Addin,
or is there something in .NET that the Ribbon depends upon and it will just
not work in any other context?
 
P

Patrick Schmid [MVP]

The third was just posted recently and contains the all-important list
of callback signatures.

Patrick Schmid [OneNote MVP]
--------------
http://pschmid.net
***
Office 2007 RTM Issues: http://pschmid.net/blog/2006/11/13/80
Office 2007 Beta 2 Technical Refresh (B2TR):
http://pschmid.net/blog/2006/09/18/43
***
Customize Office 2007: http://pschmid.net/office2007/customize
OneNote 2007: http://pschmid.net/office2007/onenote
***
Subscribe to my Office 2007 blog: http://pschmid.net/blog/feed

Thanks. I had read 1/3 and 2/3 but could never find the third article.

I'll give it a read.

--
Mark Wilson



Patrick Schmid said:
I suggest you read
http://msdn2.microsoft.com/en-us/aa338202(office.12).aspx
http://msdn2.microsoft.com/en-us/aa338199(office.12).aspx
http://msdn2.microsoft.com/en-us/aa722523(office.12).aspx

Patrick Schmid [OneNote MVP]
--------------
http://pschmid.net
***
Office 2007 RTM Issues: http://pschmid.net/blog/2006/11/13/80
Office 2007 Beta 2 Technical Refresh (B2TR):
http://pschmid.net/blog/2006/09/18/43
***
Customize Office 2007: http://pschmid.net/office2007/customize
OneNote 2007: http://pschmid.net/office2007/onenote
***
Subscribe to my Office 2007 blog: http://pschmid.net/blog/feed

Thanks Patrick.

So if I'm going to compile and link this C++ addin I'll need a header file
to #include and some .LIB file to link with.

For example where is something like RequestService or GetCustomUI defined?
--
Mark Wilson



:

Unmanaged C++ should work.

Patrick Schmid [OneNote MVP]
--------------
http://pschmid.net
***
Office 2007 RTM Issues: http://pschmid.net/blog/2006/11/13/80
Office 2007 Beta 2 Technical Refresh (B2TR):
http://pschmid.net/blog/2006/09/18/43
***
Customize Office 2007: http://pschmid.net/office2007/customize
OneNote 2007: http://pschmid.net/office2007/onenote
***
Subscribe to my Office 2007 blog: http://pschmid.net/blog/feed


I have an unmanaged C++ COM addin that works with Office XP and Office 2003.
I'd like to add support for the Ribbon UI for those situations when the addin
is installed on Office 2007. I've used VSTO 2005 SE to build a C# addin that
puts a simple button on the Ribbon. However, I currently don't develop in C#
and don't want to have to convert a lot of existing code to C#. I also don't
necessarily want mscoree.dll as the DLL that loads my application.

So my question is can Ribbon support be added to an unmanaged C++ COM Addin,
or is there something in .NET that the Ribbon depends upon and it will just
not work in any other context?
 
P

Peter Huang [MSFT]

Hi Mark,

Currently the Office 2007 is just coming in RTM version so the document
about this is less.

But based on my test, from scratch, the ATL/C++ Wizard for Shared Addin
will not add the default implement for interface IRibbonExtensibility.
So we can just add the implementation to the default class e.g. CConnect.

In VS.NET 2005 IDE, please follow the steps below.
1. Switch to the Class View, right click on the CConnect class
2. Click Add/Implement Interface
3. Complete the Wizard to select the IRibbonExtensibility in the Office 12
Com Lib.

The result should be similar with below.
1. Interface implementaion: public
IDispatchImpl<Office::IRibbonExtensibility,
&__uuidof(Office::IRibbonExtensibility), &Office::LIBID_Office, /* wMajor =
*/ 2, /* wMinor = */ 4>,
2. The header file is similar with below.
#pragma warning( disable : 4278 )
#pragma warning( disable : 4146 )
//The following #import imports the IDTExtensibility2 interface based on
it's LIBID
#import "libid:AC0714F2-3D04-11D1-AE7D-00A0C90F26F4" version("1.0")
lcid("0") raw_interfaces_only named_guids
//The following #import imports the MSO interface based on it's LIBID
#import "libid:2DF8D04C-5BFA-101B-BDE5-00AA0044DE52" version("2.4")
lcid("0") raw_interfaces_only named_guids auto_rename
#pragma warning( default : 4146 )
#pragma warning( default : 4278 )

If you still have any concern, please let me know.

Best regards,

Perter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
M

Mark Wilson

Hi Peter.

I've based my code on the sample code in KB Q230689. It doesn't have a
CConnect class. Is there any sample that shows what goes into a CConnect
class?

Also, if I switch to Class view and right click an existing class in my
solution in the VS 2005 IDE, my choices are Add Function and Add Variable. I
don't have an Add/Implement Interface choice.
 
P

Peter Huang [MSFT]

Hi Mark,

This is a Wizard generated class.
You may follow the steps below to create COM Addin skelecton.
1. Open the VS.NET 2005 IDE
2. File/New/Project
3. Other Projects Types/Extensibility, click Shared-Addin and click OK
4. Click Next and Check Create an Addin using Visual C++/ATL
5. Click Next... until the addin is complete.
6. Now you should get a Wizard generated code. the CConnect class should be
there.

You may have a try.


Best regards,

Perter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
G

greba

I was able to follow those directions. Thank you for those directions.
I've been having an impossible time getting callbacks to work. Some
people seem to have been able to get them working in a C++ add-in but I
can never follow what they've done. Could you post directions
(preferably easy to follow :) ) on how to accomplish this? Something
like adding a button to a custom tab and getting a callback called when
the button is pressed would be very helpful.

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top