This is my first Excel 2007 Add-in and I am just trying to prove functionality, it doesn't do much. Under the project type Visual Basic I selected "Office" and then "2007 Add-Ins".
I have the following code in the ThisAddIn.vb section...
Public Class ThisAddIn
Private ctpCard As Microsoft.Office.Tools.CustomTaskPane
Private Sub ThisAddIn_Startup(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Startup
' Start of VSTO generated code
Me.Application = CType(Microsoft.Office.Tools.Excel.ExcelLocale1033Proxy.Wrap(GetType(Excel.Application), Me.Application), Excel.Application)
' End of VSTO generated code
ctpCard = Me.CustomTaskPanes.Add(New ScoreCard(), "ABP Score Card")
ctpCard.Visible = True
Globals.ThisAddIn.Application.Range("A10").FormulaR1C1 = "One"
Globals.ThisAddIn.Application.Range("A11").FormulaR1C1 = "Two"
End Sub
Private Sub ThisAddIn_Shutdown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shutdown
Me.CustomTaskPanes.Remove(ctpCard)
End Sub
End Class
And the following code in the User Control section...
Public Class ScoreCard
Private Sub btn_Add_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Push.Click
Globals.ThisAddIn.Application.Range("A2").FormulaR1C1 = "One"
Globals.ThisAddIn.Application.Range("A3").FormulaR1C1 = "Two"
Globals.ThisAddIn.Application.Range("B2").FormulaR1C1 = Me.txt_One.Text
Globals.ThisAddIn.Application.Range("B3").FormulaR1C1 = Me.txt_Two.Tex
End Sub
Private Sub btn_Pull_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Pull.Click
Me.txt_One.Text = Globals.ThisAddIn.Application.Range("B10").FormulaR1C1
Me.txt_Two.Text = Globals.ThisAddIn.Application.Range("B11").FormulaR1C1
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Me.txt_One.Text = Globals.ThisAddIn.Application.Range("B10").FormulaR1C1
Me.txt_Two.Text = Globals.ThisAddIn.Application.Range("B11").FormulaR1C1
End Sub
End Class