How to get actual sheet in my workbook?

R

Raphael Saccomani

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
 
R

Raphael Saccomani

hello again,

this sample works fine!

http://support.microsoft.com/default.aspx/kb/302084


but generate a new Excel Application Work Book, i need to get actual opened
workbook.

and the codeproject code we need the workbook fullpath to open!

how to get the full path or actual excel.application class??





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
 
R

Raphael Saccomani

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top