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 

EOleException: PivotTableWizard

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi (General)
View previous topic :: View next topic  
Author Message
Joaquim
Guest





PostPosted: Mon Oct 03, 2005 1:31 pm    Post subject: EOleException: PivotTableWizard Reply with quote



Hi,

I“m trying to instantiate a instance of an Automation object (Excel)
from a SQL Statement in a Delphi application by creating a OleObject,
but I“m getting an exception class EOleException with message: "O
método PivotTableWizard da classe WorkSheet falhou"
(PivotTableWizard method of class WorkSheet has failed).

Note: I“m using Delphi 6, Office 97, windows XP and connecting a MS
SQL Server database. But when using Windows 2000 we have no problems
and the program works at all !!

Here some code:

procedure cmdGenerateExcelClick (Sender: TObject);
var
cServerName : string;
cPassword : string;
cUserName : string;
cDataBaseName : string;
Obj, Destino, SQL: Variant;

begin
with DataModule1.DataBase1.Params do
begin
cServerName := Values['SERVER NAME'];
cUserName := Values['USER NAME'];
cPassword := Values['PASSWORD'];
cDataBaseName := Values['DATABASE NAME'];
end;

Obj := CreateOleObject('Excel.Application');

Obj.Visible := bOleVisivel;

Obj.Workbooks.Add;

Destino := Obj.Range['A8'];

Sql := VarArrayCreate([0,8], VarOleStr);

Sql[0]:= (' Select * from RelPautaView ');

Sql[1]:= (' where CodEvento = ' +
DataModulo1.qMasterPautaCodEvento.AsString );

StatusBar1.SimpleText := 'Conecting to database...';

StatusBar1.Refresh;

Conexao := 'ODBC;DSN=ProdCap;DRIVER={MSSQL};SRVR=' + cServerName +
';DB=' + cDataBaseName + ';UID=' + cUserName + ';PWD=' + cPassword;

Obj.Workbooks[1].Sheets[1].PivotTableWizard(2,SQL,Destino,'Tabela
dināmica1',False, False,,,,,,,,,, Conexao);

Obj.Workbooks[1].Sheets[1].PivotTables['Tabela
dināmica1'].PivotCache.RefreshOnFileOpen := True;

StatusBar1.SimpleText := 'Conection OK...';

StatusBar1.Refresh;

End;

Thank“s for any help.

Joaquim

Back to top
Riki Wiki Google
Guest





PostPosted: Fri Oct 07, 2005 8:00 pm    Post subject: Re: EOleException: PivotTableWizard Reply with quote



Hoi Joaquim

Quote:
Thank“s for any help.

This newsgroup do not officially exist. You need to repost your
question on the Borland news server to make everybody see it and
possibly answer your question.

Take a look here:
<http://tinyurl.com/8m5nw>
which links to
<http://delphi.wikicities.com/wiki/Delphi_Newsgroups>


Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi (General) 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.