| View previous topic :: View next topic |
| Author |
Message |
Felix A. Hernandez Guest
|
Posted: Wed Aug 09, 2006 8:12 am Post subject: How do I select a sheet |
|
|
I opened an Excel workbook and is on Sheet2 and I need to go to
'MySheet' using TExcelApplication or TExcelWorksheet automation VCL
server. How do I select a sheet and make it the active sheet?
Felix |
|
| Back to top |
|
 |
Dennis Passmore Guest
|
Posted: Wed Aug 09, 2006 2:42 pm Post subject: Re: How do I select a sheet |
|
|
Once you have a TExcelApplication (Application_) you can use the
Workbooks property to tell it to open a named saved Excel file
as (fWorkbook).
Now you can use the fWorkbook.WorkSheets property to examine each Item
giving it a "Name" to see it is the WorkSheet you need as (fWorkSheet)
and then just use fWorkSheet.Activate(lcid) to make it the
Active WorkSheet.
Dennis Passmore
"Think it might be a new experience and
if you can not Pull then at least Push
the job will get done" |
|
| Back to top |
|
 |
Felix A. Hernandez Guest
|
Posted: Thu Aug 10, 2006 6:26 pm Post subject: Re: How do I select a sheet |
|
|
Dennis Passmore wrote:
| Quote: | Once you have a TExcelApplication (Application_) you can use the
Workbooks property to tell it to open a named saved Excel file
as (fWorkbook).
Now you can use the fWorkbook.WorkSheets property to examine each Item
giving it a "Name" to see it is the WorkSheet you need as (fWorkSheet)
and then just use fWorkSheet.Activate(lcid) to make it the
Active WorkSheet.
Dennis Passmore
"Think it might be a new experience and
if you can not Pull then at least Push
the job will get done"
|
I tried displaying the ExcelApplication1.Workbooks.Item[1].Name property
and that contains the name of the workbook not the name the sheet. I
need to get to a specific sheet by name in the workbook.
ExcelApplication1.Workbooks.Item[1].Name does not work.
ExcelApplication1.ActiveWorkbook.Worksheets['Stand ' + db_stand.Text];
did not work either.
Felix |
|
| Back to top |
|
 |
Dennis Passmore Guest
|
Posted: Thu Aug 10, 2006 10:59 pm Post subject: Re: How do I select a sheet |
|
|
I had not done this in a while so I put together a simple example
that I think does exactly what you are trying to do.
Get it from my website at http://www.dpassmore.com/wdata/ExcelTest.zip
Dennis Passmore
"Think it might be a new experience and
if you can not Pull then at least Push
the job will get done" |
|
| Back to top |
|
 |
|