| View previous topic :: View next topic |
| Author |
Message |
Felix A. Hernandez Guest
|
Posted: Sat Aug 05, 2006 7:29 pm Post subject: How to Name a sheet and select it by name? |
|
|
How do I name the sheet and select the sheet by name in Delphi 7 using
the TExcelApplication VCL server?
I tried the following:
ExcelApplication1.ActiveWorkbook.Name := 'Stand ' + db_stand.Text;
but I got a compile error that this is a read only property.
On selecting by name I have no idea. |
|
| Back to top |
|
 |
Dennis Passmore Guest
|
Posted: Sat Aug 05, 2006 8:46 pm Post subject: Re: How to Name a sheet and select it by name? |
|
|
The following file may give you some ideas:
http://www.dpassmore.com/wdata/StockTrksource.zip
Dennis Passmore
"If you cannot conceive the idea you
will never achieve the desired results" |
|
| Back to top |
|
 |
Deborah Pate (TeamB) Guest
|
Posted: Sun Aug 06, 2006 3:43 pm Post subject: Re: How to Name a sheet and select it by name? |
|
|
<<Felix A. Hernandez:
ExcelApplication1.ActiveWorkbook.Name := 'Stand ' +
db_stand.Text;
You name a workbook by saving it. I think you want to name
the work/sheet/.
--
Deborah Pate (TeamB) http://delphi-jedi.org
TeamB don't see posts sent via Google or ISPs
Use the real Borland server: newsgroups.borland.com
http://www.borland.com/newsgroups/genl_faqs.html |
|
| Back to top |
|
 |
Felix A. Hernandez Guest
|
Posted: Mon Aug 07, 2006 7:13 pm Post subject: Re: How to Name a sheet and select it by name? |
|
|
Deborah Pate (TeamB) wrote:
| Quote: | Felix A. Hernandez:
ExcelApplication1.ActiveWorkbook.Name := 'Stand ' +
db_stand.Text;
You name a workbook by saving it. I think you want to name
the work/sheet/.
|
I got the naming of the sheet working. Here is my code:
try
ExcelWorksheet1.ConnectTo(ExcelApplication1.ActiveSheet as _Worksheet);
ExcelWorksheet1.Name := 'MySheet';
finally
ExcelWorksheet1.Disconnect;
end;
Now all I have left is to figure out how to select the sheet named
'MySheet' using TExcelApplication and/or TExcelWorksheet VCL automation
servers.
I have some old code I wrote using Excel97 that I need to convert newer
methods. Here is my old code for making 'MySheet' the active sheet:
try
WrkBook := GetActiveOleObject('Excel.Application');
except
WrkBook := CreateOleObject('Excel.Application');
end;
WrkBook.Caption := 'Excel Automation';
WrkBook.Visible := False;
filename := WrkBook.GetOpenFilename('Excel Sheets(*.xls), *.xls');
WrkBook.Workbooks.Open(filename);
try
Sheet := WrkBook.ActiveWorkbook.Worksheets['MySheet'];
Thank you Deborah for your help.
Fair Bits...
Felix |
|
| Back to top |
|
 |
Deborah Pate (TeamB) Guest
|
Posted: Mon Aug 07, 2006 9:34 pm Post subject: Re: How to Name a sheet and select it by name? |
|
|
<<Felix A. Hernandez:
Now all I have left is to figure out how to select the
sheet named 'MySheet' using TExcelApplication and/or
TExcelWorksheet VCL automation
servers.
If you have a TExcelWorksheet component called WS:
WS.ConnectTo(ExcelApplication1.Sheets['My sheet'] as
_Worksheet);
WS.Activate;
--
Deborah Pate (TeamB) http://delphi-jedi.org
TeamB don't see posts sent via Google or ISPs
Use the real Borland server: newsgroups.borland.com
http://www.borland.com/newsgroups/genl_faqs.html |
|
| Back to top |
|
 |
|