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 

Need help with cells.find

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





PostPosted: Fri Jun 03, 2005 6:51 pm    Post subject: Need help with cells.find Reply with quote




I have a program that loads data into Excel from a query. I then run another query to get another list. I first want to verify that the item in my second list doesn't exist on my spreadsheet already. I am trying to use the cells.find but am having problems assigning the result of the cells.find function. I also need to put the result in an if statement.

I am trying the following:

worksheet.Cells.Find(DM.qryAgree.FieldByname('NI 1234').AsString,emptyparam,emptyparam,emptyparam,emptyparam,emptyparam,False,emptyparam)

What does cells.find return?
How can I put this in an if statement?

Thanks

Dwaine
Back to top
Dwaine Horton
Guest





PostPosted: Mon Jun 06, 2005 1:19 pm    Post subject: Re: Need help with cells.find Reply with quote




Chris Cheney <cjc1@nospam%ucs.cam.ac.uk%no%spam%please> wrote:
Quote:
"Dwaine Horton" <dwaine.horton (AT) york (DOT) com> wrote in
news:42a0a69b$1 (AT) newsgroups (DOT) borland.com:

worksheet.Cells.Find(DM.qryAgree.FieldByname('NI
1234').AsString,emptyparam,emptyparam,emptyparam,emptyparam,emptyparam,F
alse,emptyparam)

What does cells.find return?

A Range object.

How can I put this in an if statement?

You probably want to use its Value property.


Ok, I set the following up and I get an Invalid variant type conversion:

Var
range: variant;
begin

range := worksheet.Cells.Find(DM.qryAgree.FieldByname('X_LAWSON_INVOICE_NUMBER_YORK').AsString,emptyparam,emptyparam,emptyparam,emptyparam,emptyparam,False,emptyparam)
if range.value = DM.qryAgree.FieldByname('X_LAWSON_INVOICE_NUMBER_YORK').AsString Then
begin
....
end;

I get the error when I try to assign the range value from the cells.find to my range variable.

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.