BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to Name a sheet and select it by name?

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OLE Automation
View previous topic :: View next topic  
Author Message
Felix A. Hernandez
Guest





PostPosted: Sat Aug 05, 2006 7:29 pm    Post subject: How to Name a sheet and select it by name? Reply with quote



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





PostPosted: Sat Aug 05, 2006 8:46 pm    Post subject: Re: How to Name a sheet and select it by name? Reply with quote



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





PostPosted: Sun Aug 06, 2006 3:43 pm    Post subject: Re: How to Name a sheet and select it by name? Reply with quote



<<Felix A. Hernandez:
ExcelApplication1.ActiveWorkbook.Name := 'Stand ' +
db_stand.Text;
Quote:


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





PostPosted: Mon Aug 07, 2006 7:13 pm    Post subject: Re: How to Name a sheet and select it by name? Reply with quote

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





PostPosted: Mon Aug 07, 2006 9:34 pm    Post subject: Re: How to Name a sheet and select it by name? Reply with quote

<<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.
Quote:


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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OLE Automation All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.