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 

What cell am I in?!

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





PostPosted: Fri Sep 10, 2004 3:57 pm    Post subject: What cell am I in?! Reply with quote



Quick question.

I'm using Delphi 7.

I open an excel file and search for a specific and unique value (e.g 1234)
in that file like so:

Excel.Selection.Find('1234', Excel.ActiveCell, xlFormulas, xlPart, xlByRows,
xlNext, False).Activate;


Upon finding that value the cell that the value is in becomes the active
cell. How do I get back to Delphi information on which cell I have actually
landed in (e.g. 'A10')?

Thanks in advance for any help.

Bruce



Back to top
Mariusz Celmer
Guest





PostPosted: Fri Sep 10, 2004 5:31 pm    Post subject: Re: What cell am I in?! Reply with quote



use Excel.ActiveCell.Address

you can also loop through all matching cells without its activating (but
still getting their address) like this:

LFirstCellAddress := ''; // as string
LRange := Lsheet.Cells.Find('1234', XLApplication.ActiveCell); // as
oleVariant
while (not VarIsClear(LRange)) and (LFirstCellAddress <> LRange.Address)
do
begin
if LFirstCellAddress = '' then LFirstCellAddress := LRange.Address;
ListBox1.Items.Add(LRange.Address);
LRange := Lsheet.Cells.FindNext(LRange); // FindNext continues searching
on criteria set up in Find function.
end;

hth,
Mariusz


"Bruce McIver" <b.mciver (AT) marlab (DOT) ac.uk> wrote

Quote:
Quick question.

I'm using Delphi 7.

I open an excel file and search for a specific and unique value (e.g 1234)
in that file like so:

Excel.Selection.Find('1234', Excel.ActiveCell, xlFormulas, xlPart,
xlByRows,
xlNext, False).Activate;


Upon finding that value the cell that the value is in becomes the active
cell. How do I get back to Delphi information on which cell I have
actually
landed in (e.g. 'A10')?

Thanks in advance for any help.

Bruce






Back to top
Bruce McIver
Guest





PostPosted: Mon Sep 13, 2004 8:18 am    Post subject: Re: What cell am I in?! Reply with quote



Thanks Mariusz,

Got that working fine now.

"Mariusz Celmer" <Mariusz.Celmer (AT) poczta (DOT) neostrada.pl> wrote

Quote:
use Excel.ActiveCell.Address

you can also loop through all matching cells without its activating (but
still getting their address) like this:

LFirstCellAddress := ''; // as string
LRange := Lsheet.Cells.Find('1234', XLApplication.ActiveCell); // as
oleVariant
while (not VarIsClear(LRange)) and (LFirstCellAddress <> LRange.Address)
do
begin
if LFirstCellAddress = '' then LFirstCellAddress := LRange.Address;
ListBox1.Items.Add(LRange.Address);
LRange := Lsheet.Cells.FindNext(LRange); // FindNext continues
searching
on criteria set up in Find function.
end;

hth,
Mariusz


"Bruce McIver" <b.mciver (AT) marlab (DOT) ac.uk> wrote in message
news:4141cecf$3 (AT) newsgroups (DOT) borland.com...
Quick question.

I'm using Delphi 7.

I open an excel file and search for a specific and unique value (e.g
1234)
in that file like so:

Excel.Selection.Find('1234', Excel.ActiveCell, xlFormulas, xlPart,
xlByRows,
xlNext, False).Activate;


Upon finding that value the cell that the value is in becomes the active
cell. How do I get back to Delphi information on which cell I have
actually
landed in (e.g. 'A10')?

Thanks in advance for any help.

Bruce








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.