VSTO & .NET & Excel

December 22, 2006

Using IRibbonExtensibility’s type library with COM Add-ins

Filed under: .NET & Excel, COM Add-ins — Dennis M Wallentin @ 2:25 am

In this second post about IRibbonExtensibility I will show how we can use the library with an unmanaged COM Add-in developed in classic VB. To read the first post on the subject please see:
Creating a standalone type library for IRibbonExtensibility

#1 Make a reference to the library
The filename of the attached library in the previously blogpost is XLRibbonExtensibility.tlb but its library name is XLRibbonExtensibility Object Library (which is viewed in the helpstring section on top of the tlb file) . The later is showed in the Reference dialog in classic VB which we should set a reference to in the VB Project.

#2 Implement the library
On top of the classmodule Connection we add the following expression:

Implements IRibbonExtensibility

#3 Create the necessary procedures
Before we compile the DLL we need to add some procedures in the Connection class. These procedure are available here.

#4 Creating the configuration XML file for the Ribbon in Excel 2007
The XML file that is used here is included in the attached file RibbonX.zip (see below).

#5 Do we actually need to ship the XLRibbon.tlb file with the solution?
No – We only need it during the developing process.
The implements statement as above and all procedures that is targeting the IRibbonExetensibility are disregarded when installed on a targeting computer, for instance with Excel 2000 installed.

However, if You get some issues due to the use of this approach You should include the TLB file in the setup package.

Despite the above I still want to know if it legal or not to extract the IRibbonExtensibility information from the MSO.DLL file.

If You want to take part of the created DLL You can download the RibbonX.zip file, which includes the compiled DLL, XML file and the Helpfile. You need to registrate the DLL in order to test it. Please note that the DLL is just a test file.

I would like to take this opportunity to explicit thank John West for his kindness to introduce me to the approach and how we can solved it in a rather easily way.

In my next blogpost I will finally port myself officially to the VSTO 2.5 SE with the Transition case.

Kind regards,
Dennis

Advertisements

14 Comments »

  1. Hey Dennis,

    Really nice follow-up to your first article on this. The EULA issue remains, I suppose though?

    This really is an unusual situation in that normally we can bind to the lowest version of Office with which we are willing to work with and be assured that those features are available in the higher versions. So if you bind to Excel 2000 you would not be able to use Smart Tags, which are available in later versions, but all your code regarding Worksheets, CommandBars, etc. would all still work.

    With Excel 2007, legacy CommandBar code is essentiall defunct. Ok, technically, the CommandBars still show up, but they are not nearly the same thing as before. So, essentially, Office 2007 pretty much breaks with legacy code.

    So it is not sufficient to bind to Excel 2003 and know that it will run in 2007. It will, but with the switch from CommandBars to the Ribbon binding to Excel 2003 would leave Excel 2007 operations crippled.

    So the only approaches that I see are either:

    (1) Bind to the Ribbon.tlb as you are showing here. (Hopefully this does not break any rules), or

    (2) Create two separate Add-ins: one for 2003 and another for 2007. The code can be the same in each (other than the CommandBars vs. Ribbon code) but each project would have to be compiled separately as, say MyExcel2003Project.dll and MyExcel2007Project.dll.

    Good stuff here, Dennis, as always. And thanks to John West as well for getting this ball rolling and producing the original solution…

    Mike

    Comment by Mike Rosenblum — December 24, 2006 @ 5:11 pm

  2. Hi Mike,

    Thanks for Your comment 🙂

    >>The EULA issue remains, I suppose though?

    I have not yet received any feedback. I also know that the question has been raised directly to MSFT by a MVP but so far no comments have been made.

    I fully agree with Your stated options and the fact that the Ribbon breaks the structure we so far have been able to use and rely on.

    In 2007 the created toolbars (in the “old” way) will be added to the Add-ins tab (which is not available per default). OK, it will not be a user friendly solution but at least it works and also don’t challenge any legal aspects.

    The bottom line is that I dislike the thought of using two DLLs to do the same thing in Excel..

    Kind regards,
    Dennis

    Comment by Dennis Wallentin — December 25, 2006 @ 4:07 pm

  3. I’m not sure I see the point of creating this separate TLB file. Is this for use by developers who do NOT have a copy of Office 2007? Or does the Office 2007 MSO.DLL not include the type library information needed by VB6?

    Comment by Tom Winter — January 9, 2007 @ 1:29 am

  4. Tom,

    Thanks for Your question which I believe is not explicit covered in the blogpost.

    If we only would target Excel 2007 and we want to customize the Ribbon then it would be OK to set a reference to the Office 12 Object Library (which include IRibbonExtensibility – filename MSO.DLL) and implement the extensibility.

    To implement the extensibility the standard way requires early binding to Office 12 Object Library. Office 12 Object Library cannot be referenced to when running the same COM Add-in with Excel 2000 as it is not available.

    In order to make it possible to run the same COM Add-in with different Excel versions we, by using a standalone customized TLB file, avoid the above scenario as we don’t use the same reference. In a way we “fool” the COM Add-in.

    I hope that the above make it more understandable.

    Kind regards,
    Dennis

    Comment by Dennis Wallentin — January 9, 2007 @ 12:48 pm

  5. Hi Dennis,

    Just wanted to come and say thanks… even after this article was published over 3 years ago, it helped me a lot with a project I’m working on right now.

    Hope everything is going great with you.

    Comment by Juan Pablo González — April 12, 2010 @ 7:34 pm

    • Hello Juan Pablo 🙂

      Very nice to hear from You! Given the number of visitors, for this blog entry, it doesn’t matter that it’s now three years ago since it was published. It’s still valid.

      Things are well in my part of the world. For some unknown reason everyone get older 😉

      Take care and thanks for Your greetings,
      Dennis

      Comment by Dennis Wallentin — April 13, 2010 @ 1:16 am

  6. Thank you very much Dennis!

    Year ago it helped me to create Word and Outlook add-in with use of this magic.

    Now I’m jumping into NET and trying to understand how to make same trick with it.

    Alexey.

    Comment by Alexey Shestakov — April 22, 2010 @ 10:23 pm

  7. In step #3 you mention a link to your English site “Using IRibbonExtensibility’s type library with COM Add-ins” (whose title strangely sounds like the page I am already on) but the link is broken.

    I am specifically interested in adding some procedures in the Connection class that is supposed to be covered in the above link.

    This is to be used in a VB6 project.

    -Maurice

    Comment by Maurice — July 16, 2010 @ 5:25 pm

    • Maurice,

      Thanks for pointing it out to me. Because of the reconstruction of my English site the article is no longer available there.

      But I will make it available here as a textfile which You can download. I hope that I can do it this week.

      Thanks,
      Dennis

      Comment by Dennis Wallentin — July 19, 2010 @ 1:56 am

  8. Hi all,

    I have now updated so that a text file is available with all the procedures via the article here.

    Kind regards,
    Dennis

    Comment by Dennis Wallentin — July 24, 2010 @ 3:13 pm

  9. Hi Dennis,
    Is is possible to adapt your method for a managed .NET add-in?

    Comment by Natan Yellin — June 1, 2011 @ 6:34 pm

    • Natan,
      I have never thought of it. Why do You want to do it?

      Kind regards,
      Dennis

      Comment by Dennis Wallentin — June 1, 2011 @ 9:09 pm

      • Never mind. I wanted to package one version for Office 2003 and 2010. I didn’t realize it was easy to do so without a type library.

        Comment by Natan Yellin — June 2, 2011 @ 10:37 am


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: