13.07.2015 Views

Microsoft SharePoint. Building Office 2007 Solutions in VB 2005 ...

Microsoft SharePoint. Building Office 2007 Solutions in VB 2005 ...

Microsoft SharePoint. Building Office 2007 Solutions in VB 2005 ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

346CHAPTER 9 ■ SHAREPOINT AND MICROSOFT OFFICEAlong with the components and stubbed-out code, the new solution also conta<strong>in</strong>s a setupproject. This setup project is suitable for deploy<strong>in</strong>g add-<strong>in</strong>s directly to client mach<strong>in</strong>es. Creat<strong>in</strong>gan add-<strong>in</strong> and mak<strong>in</strong>g it available to clients us<strong>in</strong>g the project templates can be a fairlysimple process.Creat<strong>in</strong>g <strong>Office</strong> <strong>2007</strong> Add-Ins<strong>Office</strong> <strong>2007</strong> supports the concept of an add-<strong>in</strong> that lets you add custom functionality to <strong>Office</strong>applications through the use of buttons that appear on the ribbon. Typically, add-<strong>in</strong>s are <strong>in</strong>itiatedby <strong>in</strong>teract<strong>in</strong>g with buttons on the ribbon that <strong>in</strong> turn exercise the application objectmodel to achieve some functionality. For example, you could place a button on the Insert tabthat adds a standard legal disclaimer to a document when it is pushed. The actual functionalityof an add-<strong>in</strong> is limited only by what you can do with the .NET Framework and the objectmodel of the targeted <strong>Office</strong> application.Once you have started a new project <strong>in</strong> Visual Studio that targets a particular application,you can add buttons to the ribbon by us<strong>in</strong>g the Ribbon Support component. The Ribbon Supportcomponent is available <strong>in</strong> the Add New Item dialog. When you add this component, VSTO<strong>2005</strong> SE adds a new class to your project along with an XML file that holds button def<strong>in</strong>itions.Follow these steps to start a new add-<strong>in</strong> project:1. Select Start ➤ All Programs ➤ Visual Studio <strong>2005</strong> ➤ Visual Studio <strong>2005</strong>.2. In Visual Studio, select File ➤ New ➤ Project from the ma<strong>in</strong> menu.3. In the New Project dialog, select Visual Basic ➤ <strong>Office</strong> ➤ <strong>2007</strong> Add-Ins from the ProjectTypes tree.4. Select Word Add-In from theVisual Studio templates.5. Enter HelloAddIn <strong>in</strong> the Name field and click the OK button.6. In the Solution Explorer, right-click the HelloAddIn project and select Add ➤ New Itemfrom the context menu.7. In the New Item dialog, select the Ribbon Support component.8. Name the new component MyAddInsTab.vb and click the Add button.Load<strong>in</strong>g the Ribbon SupportWhen the Ribbon Support component is added, it comes with some code to automaticallyadd the new elements to the target application’s ribbon, but this code is commented out. Inorder to load your new elements, you simply have to uncomment this code, which overridesthe RequestService method of the add-<strong>in</strong>. This is the method that is called when the <strong>Office</strong>application loads your Ribbon Support component. The code <strong>in</strong> List<strong>in</strong>g 9-7 shows theuncommented code from the MyAddInsTab.vb file.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!