Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem with createOleObject

Status
Not open for further replies.

room24

Programmer
Dec 28, 2003
83
JM
when i compile my code below using delphi 6 i get this message
"undeclared identifier 'VarArrayCreate'"
can anyone explain please how can this be

here is the section of the code

procedure TfmChequeGrid.sbArrayClick(Sender: TObject);
{ declare array }
var
RowCount : integer;
count_index : integer;
CheckArray, excelapp, excelsht : variant;

begin
inherited;

CheckArray := VarArrayCreate([0,rowcount,0,8], varOleStr);
CheckArray[0,0] := 'Account';
CheckArray[0,1] := 'Ticker';
CheckArray[0,2] := 'Currency';
CheckArray[0,3] := 'Cheque Amount';
CheckArray[0,4] := 'Cheque Type';
CheckArray[0,5] := 'Status';
CheckArray[0,6] := 'Cheque Number';
CheckArray[0,7] := 'Cheque Date';

RowCount := quCheque.RecordCount;

quCheque.first;

while not quCheque.EOF do
begin
count_index := count_index + 1;

CheckArray[count_index,0] := quChequeAccountNameNumber.AsString;
CheckArray[count_index,1] := quChequeTicker.AsString;
CheckArray[count_index,2] := quChequeCurrency_name.AsString;
CheckArray[count_index,3] := quChequeCheque_amount.AsString;
CheckArray[count_index,4] := quChequeCheque_type.AsString;
CheckArray[count_index,5] := quChequeStatus.AsString;
CheckArray[count_index,6] := quChequeCheque_number.AsString;
CheckArray[count_index,7] := quChequeCheque_date.AsString;

quCheque.next;

end;
{initialize Excel }
excelapp := CreateOleObject('Excel.Application');
excelapp.Visible := False;
excelapp.Workbooks.Add;
excelsht := excelapp.WorkSheets.Item['Sheet1'];
excelsht.Activate;

{transfer entire array to spread sheet }

excelsht.Range[excelsht.Cells.Item[1,1],
excelsht.Cells.Item[(count_index),8]].value := CheckArray;

{ save and close }

excelapp.displayalerts := False;
excelsht.SaveAs('C:\Sale.xls');
excelapp.WOrkbooks.CLose;
excelapp.quit;

end;

end.





room24 (Programmer) Aug 4, 2004
this is my uses clause below

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, GRIDFORM, Db, DBTables, Menus, StdCtrls, Grids, DBGrids, Buttons, ExtCtrls, ComObj, variants, ComCtrls;

i have included variants which solve the earlier problem with varArrayCreate but now when i compile i get it complains about "CreateOleObject" so now i have included
ComObj but it is now complaining about
identifier redeclared "ComObj"

help please

 
Hi room

I suggest that you first check both of uses clauses: in interface section and in implementation section. Or perfom "find" operation in your unit searching for "ComObj"

--- McMerfy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top