Hello Guys!
I solved my problem!
In the Excel Addin class have the method this.Initialize();
i go to definition and see that he give the Excel Application class:
this.GetHostItem<Microsoft.Office.Interop.Excel.Application>(typeof(Microsoft.Office.Interop.Excel.Application), "Application");
then i create a simple static class that have one member type of
Microsoft.Office.Interop.Excel.Application
and i can use this class in my ribbon control:
private void button1_Click(object sender, RibbonControlEventArgs e)
{
Excel.Application oXL;
Excel._Workbook oWB;
Excel._Worksheet workSheet;
Excel.Range oRng;
try
{
oXL = Functions.m_app;
//Get actual workbook.
oWB = Functions.m_app.ActiveWorkbook;
workSheet = (Excel._Worksheet)oWB.ActiveSheet;
workSheet.Cells[1, 1]="funcioneiiii";
//MessageBox.Show();
MessageBox.Show(workSheet.get_Range("A1",
"A1").Text.ToString());
}
catch (Exception theException)
{
String errorMessage;
errorMessage = "Error: ";
errorMessage = String.Concat(errorMessage,
theException.Message);
errorMessage = String.Concat(errorMessage, " Line: ");
errorMessage = String.Concat(errorMessage,
theException.Source);
MessageBox.Show(errorMessage, "Error");
}
}
thanks all for help!
God Bless!
Jacob Skaria said:
http://www.codeproject.com/KB/cs/Excel_Application_in_C_.aspx
If this post helps click Yes
---------------
Jacob Skaria
Raphael Saccomani said:
Hello all, i am trying to developer a excel addin with Visual Studio
2008/Office 2007 and C#!
my question is:
I create a simple Ribbon control with my button, and in the Button click i
want to get the worksheet [0] (fist) and read some cells to paste this values
in word..
my i have no ideia how to do this, can anybody help me?
Tools:
visual studio 2008, Office addin development
Language:
C#
Office Version:
2007