Re-purposing Office commands through code - c#

Office Ribbon buttons and other commands can be "re-purposed" using XML and onAction method. I have already done that successfully. Is there an equivalent C#/Object Model way of doing it too? Google hasn't shown much promise.
Background: The main Ribbon of my add-in is using visual designer. If I use the XML method of re-purposing, my main Ribbon will not be loaded. Other than this road bump, I'm interested in finding the solution in general too.

After spending some time, I learned that there is no way of doing this from C# code. I must switch to XML Ribbon approach. Fortunately the Visual Designer can help you translate your existing ribbons into XML format. You can right-click the Ribbon in Visual Designer and choose "Convert to XML" command.
I also found that XML Ribbon approach is far more powerful in the sense that it can access Office 2013 and 2016 features that the Visual Designer cannot. For example the Office Backstage and new context menus are only accessible in XML approach.

Related

How to make a quick analysis-like floating menu in VSTO

I want to know anybody knows if there is in VSTO a control or a way to create a popup like Quick Analysis that appears at the right-bottom of a given range:
I'm creating an Excel plugin in VS2013 with C#, the plugin should be compatible on Excel 2007, 2010 and 2013. If such control can only be created on the latest version of Excel (2013) that may not be an option for deploy. I´ve already created a traditional Windows form to do this, but I'll like to know if there are better ways to show new controls to the user, closer to where the action is occurring. Thanks!

Outlook 2010 extensibility, which API to choose?

I would like to add some features to the Outlook 2010 application.
Those features will include:
adding a button to the ribbon,
manipulating the calendar,
display Windows Form after the ribbon button is pressed.
I managed to find out that there are several ways to interfere with Outlook programmatically. They are: the object model, PIA, MAPI, and auxiliary APIs. (Source)
Which approach would you recommend to achieve the above requirements? I would like to use C#. Any tip on Outlook development is very welcome.
VSTO is probably the easiest way to do that, since it's got designer support in Visual Studio for working with the ribbon.
You can get started by using Create New Project in VS, and expanding the "Office" menu.

How to reuse visual studio for office ribbons and code across different ofiice document types

I am new to Visual studio for office (VSTO)
I am using VSTO to create an addon for PowerPoint, Word and Excel. The ribbons (UI) look-and-feel will be the same for the addons. Here is my question:
How can I set up the visual studio such that I use only one code base for these addons and reuse Ribbon UI; or must I creates separates solutions each for PowerPoint, Word and Excel?
Out of the box it is pretty hard to achieve what you are after.
If you use the VSTO Contrib project's Ribbon Factory you can reuse the ribbon viewmodel's between all of the add-ins pretty easily I think.
http://vstocontrib.codeplex.com/
In addition, I would then manually go and edit your .csproj file of the shared project to conditionally include specific references so you do not have all the office interop libraries referenced at once.

Creating a 'Custom Designer' Visual Studio 2010 Add-in

A major part of our work is creating and manipulating certain XML files, for which have a custom editor. The editor is starting to get creaky and we are looking at building a replacement. Since VS2010 has recently arrived, ostensibly with an improved add-in architecture (MEF?), I am interested in the possibility of building the editor as a custom editor within Visual Studio.
It would have to appear in the same way as the code editor or the Designer - a tab item, of which there can be many open at once, containing the GUI we use to edit the files. It would integrate with VS's Edit menu. It could use the output window to display messages. It would appear the same as any other editor within Visual Studio.
Right now, I am looking for examples of add-ins that work in a similar way - ideally with source code - to see whether this model would suit our requirements. I am also looking for any documentation or tutorials relevant to creating a VS2010 add-in, or information about VS2008 add-ins if this is still relevant.
Any input is welcome. Thanks!
You want to look at the Managed Extensibility Framework for VS 2010. Since 2010 is written in .net you can create add on components using it.
Code editor extension for VS 2010.
Working with MEF
Custom Editor Extensions
Update:
Since someone asked in a comment, I thought I would post this link on creating add ons for vs 2008: http://msdn.microsoft.com/en-us/vstudio/bb968855.aspx

Programatically adding a Ribbon to Microsoft Word 2007

I have a project that adds functionality to Microsoft Word using an XML Expansion Pack. Currently, when the document we give the customer is opened, it loads our pack, which executes the SmartDocInitialize method which adds things to the main menu and toolbar using Microsoft.Office.Core.CommandBar.Controls.Add and the like. Without modifications, when opened in Word 2007 these buttons are added on the Add-Ins ribbon tab, but this isn't ideal since the buttons are all small, not grouped properly, and there is no way to bring the Add-Ins tab to the front when the document is loaded.
I would like to keep this functionality the same if the document is opened in Office 2003, but if the document is opened in Office 2007, I would like to read in an xml file which describes my new Ribbon tab and all of the buttons. Everything I've been able to find online has seemed to lead to the Ribbon file only being loaded if you have a very specific combination of magic (build in Visual Studio and it works, but no information on how you would deploy it to a users box) and will only work if you have an entire project created originally with the Visual Studio tools for Office properties, which I don't currently have.
Our development environment is XP, Visual Studio 2005, C#, .NET 2.0
The Ribbon UI is just not as programatic as the old CommandBars UI. I don't think you can do what you want. As far as I know the only way to programatically modify the Ribbon UI is to have a (COM) Add-in implement the IRibbonExtensibility interface and return a custom XML file (with the Ribbon definition) from the GetCustomUI method. There is no way to add or remove buttons one at a time like you could with the CommandBars UI. It's just totally different. I don't believe you can do what you want from some macros in a document.
I'm not familiar with XML expansion packs, but if you have to install them on the user's PC, perhaps you could install an add-in as well that could load the appropriate ribbon XML for you.
This isn't as hard as it seems.
If you already have your ribbon buttons hooked up to some VBA macros in the document, then you just need to add a reference in your VBA project to your com visible .net assembly.
The .net assembly in addition to being marked com visible (so it shows up as a type library in the references dialog box), has to have some methods that are setup to be callable from VBA.
google "vba .net callable"
its not difficult, mark class as com visible, declare it with a ProgID attribute, make methods public, make sure your methods return simple types, and use regasm to register the assembly on the target machine (not needed on dev box).

Categories