Add method, the second argument is the text that will display in
the title bar of the task pane when it is displayed. Finally, we make the task pane visible.
Creating an Excel UserForm Using a Windows Form So far, we??™ve created a task pane with two commands
and added code to our add-in project to display the custom task pane. The last things
for us to do are add controls to our Windows form to collect data and add commands to put
the data on the active worksheet.
1. Open NewEmpForm.vb in Design view by double-clicking it in the Solution Explorer.
2. Add six labels, six text boxes, and two Button controls from the Common Controls
Toolbox, and lay them out as shown in Figure 9-23.
CHAPTER 9 n ACTIVEX AND .NET 344
Figure 9-23. Completed employee data entry UserForm
3. Name the text boxes and buttons per Table 9-1.
Table 9-1. New Employee Form Control Properties
Item Property Value
Form Text New Employee Form
TextBox1 Name txtFName
TextBox2 Name txtMidInit
TextBox3 Name txtLName
TextBox4 Name txtDOH
TextBox5 Name txtTitle
TextBox6 Name txtReportsTo
Label1 Text First Name
Label2 Text Mid Init
Label3 Text Last Name
Label4 Text Date of Hire
Label5 Text Job Title
Label6 Text Reports To
Button1 Name btnSave
Button1 Text Save
Button2 Text btnCancel
Button2 Text Cancel
Now that we have our controls set, let??™s add code to create the display form in Excel 2007
and place the data from our Windows form onto the worksheet.
4. Display the Save button code stub by double-clicking the Save button.
Pages:
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316