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 307 | Next

Jim DeMarco

"Pro Excel 2007 VBA"


12. Select btnCancel from the Class Name drop-down list on the code designer.
13. Select its click event from the Method Name list.
14. In the btnCancel_Click event code stub, add the following line of code:
Close()
That is all the code we need to write. Now let??™s run the application and see how it works.
Running the Add-In Now that the user control, the Excel Add-in, and the Windows form have all
been coded, let??™s run the project and take a look at what we??™ve done.
1. Run the project by selecting Debug ?¤ Start Debugging or pressing the F5 key.
Excel 2007 opens with a blank workbook displayed and our custom task pane anchored to
the right of the workbook, as shown in Figure 9-24.
Figure 9-24. Excel 2007 workbook with custom task pane
2. Click the New Employee button on the HR task pane to display the data entry form.
3. Enter data on the New Employee form. Sample data is shown in Figure 9-25.
CHAPTER 9 n ACTIVEX AND .NET 348
Figure 9-25. New Employee form with sample data
4. Click the Save button to place the data on the worksheet and format the sheet, as
shown in Figure 9-26.
Figure 9-26. Data and formatting applied to active worksheet
5. Close the workbook without saving.
6. In Visual Studio 2005, save the project file.
nCaution As with the previous example, the add-in will remain loaded for all Excel workbooks until you
manually remove it.
CHAPTER 9 n ACTIVEX AND .NET 349
Summary
We??™ve created some very interesting code using both classic VB (6.


Pages:
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319