Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default How to get actual sheet in my workbook?

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



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default How to get actual sheet in my workbook?

You may refer

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

To read values you can either use

variable = Range("A" & n)
where A is the column name and n is the row number

OR
variable = Cells(x,y)
where x is the row number and y is the column number



--
If this post helps click Yes
---------------
Jacob Skaria


"Raphael Saccomani" wrote:

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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default How to get actual sheet in my workbook?

http://www.codeproject.com/KB/cs/Exc...ion_in_C_.aspx

If this post helps click Yes
---------------
Jacob Skaria


"Raphael Saccomani" wrote:

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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default How to get actual sheet in my workbook?

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" wrote:

http://www.codeproject.com/KB/cs/Exc...ion_in_C_.aspx

If this post helps click Yes
---------------
Jacob Skaria


"Raphael Saccomani" wrote:

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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default How to get actual sheet in my workbook?

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.Ap plication(typeof(Microsoft.Office.Interop.Excel.A pplication), "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" wrote:

http://www.codeproject.com/KB/cs/Exc...ion_in_C_.aspx

If this post helps click Yes
---------------
Jacob Skaria


"Raphael Saccomani" wrote:

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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why is the actual calculation different from actual sample Joe Excel Discussion (Misc queries) 4 May 1st 10 11:46 PM
How do I print sheet , with actual file save date in footer? irfy Excel Worksheet Functions 6 June 26th 08 12:01 AM
need macro to call a workbook w/o the actual name of the workbook Jon Peltier Excel Programming 0 December 18th 06 10:01 PM
Select sheet tabs in workbook & save to separate workbook files stratocaster Excel Worksheet Functions 2 March 1st 06 03:35 PM
projected cash flow and actual on same sheet Jack Excel Discussion (Misc queries) 0 April 14th 05 02:19 PM


All times are GMT +1. The time now is 07:14 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"