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

Jim DeMarco

"Pro Excel 2007 VBA"

NET 343
11. Add the following code to btnEmail_Click:
Dim rng As Excel.Range
rng = Globals.ThisAddIn.Application.Range("A6")
'code to handle e-mail here
MsgBox("Sending new hire information for" & rng.Text & " to Systems Group")
This is basically a dummy function to simply show that we can process the data from the
task pane and place it anywhere else we??™d like.
12. Close the HRTaskPane design and code windows. If prompted to save changes, choose
Yes.
Showing the Custom Task Pane Now that we??™ve got our custom task pane set up, we need add
code to show it when our add-in starts up. The ThisAddIn.vb code file that Visual Studio 2005
created for us came complete with two code stubs for handling add-in startup and shutdown.
nNote The startup method contains one line of code generated by VSTO. This tells the add-in what
application it??™s attaching itself to.
1. Display the ThisAddIn.vb code window by clicking its tab in the Visual Studio display
area (if it??™s not there, double-click it in the Solution Explorer).
2. Place the insertion point in the blank line below the end of the VSTO-generated code.
3. Add the following code to display the HRTaskPane control:
Dim MyTaskPane As New HRTaskPane
Dim MyCustomTaskPane As Microsoft.Office.Tools.CustomTaskPane = ??
Me.CustomTaskPanes.Add(MyTaskPane, "HR Tasks")
MyCustomTaskPane.Visible = True
This code adds our HRTaskPane control to the add-in??™s CustomTaskPanes collection. In the
call to the CustomTaskPanes.


Pages:
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315