At times we would like to create our own Addin project for Office application. This can be done using the Addin Projects in Visual Studio.
Visual studio has stopped providing support for Shared addin project and at times we would like to have addin which would work in all major office application like Excel, Word, Powerpoint, Outlook etc.
Visual Studio 2010
Visual Studio 2013
So Microsoft has removed the shared addin project. Now if you want to create addin, you can only do for specific application.
So to solve the Problem. I downloaded the template project from this site.
Here David gives instruction on how to use the project. You can download the template this works for Excel, Word, Powerpoint and Outlook and register using regasm and it will show up in your Office application Ribbon.
Here’s the link to the same project, I’ve put in the (http://georgemkurian.com/download) section so that you download from here, incase some issue is present with the original site.
Here’s the modification which I did for using for my project.
I commented the below lines in ThisAddIn_Startup(), As it was giving error.
Ribbon Specific action can be handled in this code. Rest of the properties like type of button, size of button and the icon can be done in the xml itself.
3) I renamed the project to my use, I wanted to build one Metadata editor for excel, word, powerpoint document hence I renamed to project to MetaEditor.
4) Changed all the guid to new guid values which you can get from guid generator.
5) Rename the addin and its description here
6) My project needed only Excel, word, Powerpoint support hence I removed the outlook specific code.
7) Also I didn’t need the TaskPane, hence I removed that as well.
8)You can add your own Buttons in xmls which would be in the resources folder.
9) For giving icons, Add new icon in the resource and add following code in getImage Function which you need to add in connect.cs as shown below and in xml add following line
Now you are ready to go. You can add different dialogs and use Ribbon button to laumch it.
For getting office specific functionality you can directly use following codes, I’m giving you example of Excel, this you can use for any application only thing which would change is the Type of application specified and the Document/Page it returns.
Microsoft.Office.Interop.Excel.Worksheet oSheet = null;
oExcelApp = Connect.office.GetExcel();
oSheet = (Excel.Worksheet)oExcelApp.ActiveSheet;
Here’s the screenshot of the project I had done. It will list all the Custom Properties, Shape objects, Document Variables, Tags etc in Excel, Word, Powerpoint Workbook/Document/Presentations. I’ll add link to my blog later giving information about this tool.
That’s all Folks. Let me know if you face any issues or need any help.