fill a value into a cell in Excel / Office Add-In

  • Thread starter Thread starter Peter Smith
  • Start date Start date
P

Peter Smith

Hello,
how do I put a value in a cell in Excel XP
I'm programming an add-in, so all the variables (excelApp ..) work,
I'm just putting the code snipplets here.
click on the Add-in button in the toolbar executes a windows form. in
this form are a textbox and an ok button.


public void showButton_Click (Microsoft.Office.Core.CommandBarButton
barButton, ref bool somebool)
{
object temp1 = new object();
if (this.myAddin.ShowDialog() ==
System.Windows.Forms.DialogResult.OK)
{
temp1 = myAddin.textBox1.Text.ToString();
// note: this works! the value is there!
System.Windows.Forms.MessageBox.Show(temp1.ToString());

// why doesn't this work ? i know temp1 is there (the message
box)
// but the value isn't in the active excel cell.
excelApp.ActiveCell.Value2 = temp1;
}
}

can someone help me ?
cheers
-Peter



}
 
Peter,

Assigning temp1 into a cell really does nothing, as there is no kind of
representation of that object. If anything, you should be assigning
something like a string, or a number into it.

Hope this helps.
 
Back
Top