I am trying to send Data from text boxes in my windows form to specific cells in excel. I am forgetting to do something because i keep getting this error...
Error 1 'ExcelWorkbook1.ThisWorkbook' does not contain a definition for 'textBox1' and no extension method 'textBox1' accepting a first argument of type 'ExcelWorkbook1.ThisWorkbook' could be found (are you missing a using directive or an assembly reference?)
This is the code I am trying to use in ThisWorkbook.cs.....
public void WriteStringToCell (string formData)
Excel.Worksheet wks = this.ActiveSheet as Excel.Worksheet;
wks.Range["F3"].Value2 = this.textBox1.Text;
wks.Range["E8"].Value2 = this.textBox2.Text;
wks.Range["F8"].Value2 = this.listBox1.Text;
When i direct reference it right to excel like this...
wks.Range["F10"].Value2 = "Bla3";
wks.Range["F11"].Value2 = "Bla3";
wks.Range["F12"].Value2 = "Bla2";
wks.Range["F13"].Value2 = "Bla3";
It Works Fine but obviously that's not what I'm looking to do. I need the data to go from the text boxes and list boxes on the windows form to excel.
This is what i have on the even handler for the button... (I want all data to be transferred with one button click)
private void button1_Click(object sender, EventArgs e)
Globals.ThisWorkbook.WriteStringToCell(this.textBox1.Text);
this.Dispose();
I know this is wrong and i have no idea what needs to go in this event handler. I am very new to VSTO as I'm sure u know by reading this. After saying that I ask that your answer is very straight forward as i have searched forums for days not finding help.