Modifying the Connect Class Module Code

If you were (for example) creating an Excel 2007 add-in using VSTO 2005 with the 2007 upgrade, you could add Ribbon support to your add-in by simply adding a Ribbon Support item to your project. Visual Studio 2005 lacks a Ribbon Support item, and VSTO doesn't support creating Access add-ins, so this step requires extensive manual modification of the Connect class module, to support working with Access and the Ribbon.

In the OnConnection method, modify the rows that set the application (Access) and add-in variables as follows:

appAccess = DirectCast(application, _

Microsoft.Office.Interop.Access.Application) addInInstance = DirectCast(addInInst, _ Microsoft.Office.Core.COMAddIn)

Next, modify the two lines that set the Access and add-in variables as follows:

appAccess = DirectCast(application, Access.Application) addInInstance = DirectCast(application, Core.COMAddIn)

Add another Implements statement to the Connect class as follows:

Implements Extensibility.IDTExtensibility2 Implements IRibbonExtensibility

If all this manual modification of the Shared add-in code is getting tedious, hopefully the next version (v. 3) of VSTO will include an Access template that will eliminate most of the hand-coding for support of Access Shared add-ins and the Ribbon.

After adding the Implements IRibbonExtensibility line, a new function stub should appear in the Connect class module, GetCustomUI.

If you don't see the function stub, try doing a Save All. If it still doesn't appear, just type in the whole function.

Add a line of code to this function, as listed next:

Public Function GetCustomUI(ByVal RibbonID As String) As String _

Implements Microsoft.Office.Core.IRibbonExtensibility.GetCustomUI Return My.Resources.Ribbon End Function

Finally, open the Assembly.vb class from the Solution Explorer and add information about the add-in (you don't have to fill in all the information), as shown in Figure 16.18.

This completes the general changes to the Connect class module; now you need to add code for your add-in's specific functionality.

Adding Assembly information to the add-in.

Assemblylnfo.vb*1 Ribbon.xml Connect,vb File System (Create ObjectsSetup] Object Browser ? X

Imports System.Reflection — Imports Systen.Runtime.InteropSeruices

E " General Information about an assembly is controlled through the following " set of attributes. Change these attribute values to modify the information 1 associated nith an assembly.

-'TODO: Review the values of the assembly attributes

<Assembly: AssemblyTitle("Create 0bjects")>

<Assembly: AssemblyDescriptionfCreate Access table, form and report")>

<Assembly: AssemblyCompany("Helen feddema")>

<Assembly : AssemblyProduct("")>

<Assembly : Assemblycopyright(■"")> < Assembly : AssemblyTi"ademark("")> <Assembly : AssemblyCulture("")>

■embly consists of the fallowing four ualues:

Uersion information for .

Major Uersion Minor Uersion Revision Build Number

Vou can specify all the values or you can default the Build and Revision N by using the '*' as shown below:

<Assembly: AssemblyUi

<Assembly: ComUisible(True)> <Assembly: CLSCompliant(False)>

0 0

Post a comment