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 

Get Recordcount - Excel QueryTable

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





PostPosted: Thu Jan 29, 2004 6:34 pm    Post subject: Get Recordcount - Excel QueryTable Reply with quote



Hello,

I'm using Excel Automation in a Delphi application. For that I use a
TOleContainer component. I create a QueryTable object through code like the
following:

ExcelQry:=
IDispatch(OleContainer1.OleObject.Application.ActiveWorkbook.ActiveSheet.Que
ryTables.Add
(ConnStr,OleContainer1.OleObject.Application.ActiveCell,SQL)) as
_QueryTable;

with ExcelQry do
begin
Name := 'SQL';
FieldNames := False;
RowNumbers := False;
FillAdjacentFormulas := False;
PreserveFormatting := True;
RefreshOnFileOpen := False;
BackgroundQuery := True;
RefreshStyle := xlInsertDeleteCells;
SavePassword := True;
SaveData := True;
AdjustColumnWidth := True;
RefreshPeriod := 0;
PreserveColumnInfo := false;
MaintainConnection:= False;

Refresh(True);
end;

I would like to know the result query's record count. A QueryTable object
has a property called Recordset. But exceptions are raised when I try
accesssing it. What follow is sample code describing what I am doing to
achieve this:

ShowMessage(IntToStr(OleContainer1.OleObject.Application.ActiveCell.QueryTab
le.Recordset.RecordCount));

By doing this I get an exception with this message : "Not a DAO RecordSet
DataSource"

Could anyone please help or shed some light on the matter ?



Thanks in advance ,

Cris




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.