SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 296 | Next

Jim DeMarco

"Pro Excel 2007 VBA"

Message)
Finally
MsgBox(dsReturn.Tables("Table1").Rows.Count & " Records")
End Try
Return dsReturn
End Function
That completes our work on the data access component. Let??™s bring our attention back to
the add-in project that Visual Studio 2005 created for us.
The Add-In Project
When we created our add-in project, Visual Studio 2005 created the NWindDataAddIn
project, and it created a deployment project named NWindDataAddInSetup. Within the
NWindDataAddIn project, we have one file, named ThisAddIn.vb. This is where we??™ll put the
code that will run on our client Excel applications.
Before we begin, we must add a reference to our data component.
1. In the Solution Explorer, select the NWindDataAddIn project.
2. Right-click the project and choose Add Reference to display the Add Reference dialog box.
3. On the Projects tab, select NWindDataAccess, as shown in Figure 9-16.
Figure 9-16. The Add Reference dialog box
4. Click OK.
5. In the Solution Explorer, double-click the ThisAddIn.vb file to open the code window.
CHAPTER 9 n ACTIVEX AND .NET 335
Add-in projects include one line of code in the startup method referencing the Excel
application, as shown in Figure 9-17.
Figure 9-17. The predefined add-in project code
6. Place the insertion point in the blank line above the ThisAddIn_Startup method.
7. Add the following module-level variable declarations:
Private m_oNWind As NWindDataAccess.NWindData
Private m_oSheet As Excel.Worksheet
Private m_oDS As DataSet
Here, we create an object to hold a reference to our data component and create variables
to hold references to an Excel worksheet and our DataSet.


Pages:
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308