 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Felix A. Hernandez Guest
|
Posted: Thu Aug 03, 2006 6:27 pm Post subject: ExcelApplication1.Range['A1','J1'].Value Help Syntax error |
|
|
I am getting the following error:
[Error] ExcelCode.pas(51): '[' expected but ':=' found
On this code:
Range['A1','J1'].Value := VarArrayOf(['Order No',
'Cust No','Sale Date','Emp No',
'Ship Via', 'Terms','Items Total',
'Tax Rate','Freight','Amount Paid']);
Here is the complete code for the ButtonClick1 Method:
procedure TForm1.Button1Click(Sender: TObject);
var
LineNumber, LCID : Integer;
LineString : string;
begin
with SaveDialog1 do
begin
FileName :='';
Filter:= 'Excel files|*.XLS;All Files|*.*';
DefaultExt := 'XLS';
Title := 'Exporting to Excel';
if execute then
begin
LCID := GetUserDefaultLCID;
//ExcelApplication1.Range['A1','J1'].Text
with ExcelApplication1 do
begin
connect;
try
visible[LCID] := true;
Workbooks.Add(EmptyParam,LCID);
Range['A1','J1'].Value := VarArrayOf(['Order No',
'Cust No','Sale Date','Emp No',
'Ship Via', 'Terms','Items Total',
'Tax Rate','Freight','Amount Paid']);
//Format Heading
with Range['A1','J1'] do
begin
HorizontalAlignment := xlcenter;
VerticalAlignment := xlBottom;
Wraptext := false;
Orientation := 0;
ShrinkTofit := false;
MergeCells := false;
Font.Bold := true;
end; // Range
//Save Workbook
ActiveWorkbook.SaveAs(FileName, xlNormal, EmptyParam,
EmptyParam, false, false,
xlNochange, xlUserResolution, False, EmptyParam,
EmptyParam, EmptyParam,
LCID);
quit;
finally
disconnect;
end; //try
end; // ExcelApplication1
end; // Execute
end; // SaveDialog1
end; // Button1Click |
|
| Back to top |
|
 |
Deborah Pate (TeamB) Guest
|
Posted: Thu Aug 03, 2006 10:13 pm Post subject: Re: ExcelApplication1.Range['A1','J1'].Value Help Syntax err |
|
|
<<Felix A. Hernandez:
[Error] ExcelCode.pas(51): '[' expected but ':=' found
Value takes an LCID in ExcelXP+. You can just use the
Value2 property instead.
--
Deborah Pate (TeamB) http://delphi-jedi.org
TeamB don't see posts sent via Google or ISPs
Use the real Borland server: newsgroups.borland.com
http://www.borland.com/newsgroups/genl_faqs.html |
|
| Back to top |
|
 |
Felix A. Hernandez Guest
|
Posted: Thu Aug 03, 2006 10:57 pm Post subject: Re: ExcelApplication1.Range['A1','J1'].Value Help Syntax err |
|
|
Deborah Pate (TeamB) wrote:
| Quote: | Felix A. Hernandez:
[Error] ExcelCode.pas(51): '[' expected but ':=' found
Value takes an LCID in ExcelXP+. You can just use the
Value2 property instead.
|
Range['A1','J1'].Value[LCID] := VarArrayOf(['Product',
'Description','Begin Issue','Addl Issue',
'Addl Issue', 'Total Issue','Returns',
'Sold','Gross Price','Extended Price']);
Compiles ok, but I get 'OLE error 800A03EC'
I am using Delphi 7. Am I missing something for Delphi 7?
The Value2 works, but I am still curious why Value[LCID] did not work.
Range['A1','J1'].Value2 := VarArrayOf(['Product',
'Description','Begin Issue','Addl Issue',
'Addl Issue', 'Total Issue','Returns',
'Sold','Gross Price','Extended Price']);
Thank you |
|
| Back to top |
|
 |
Deborah Pate (TeamB) Guest
|
Posted: Fri Aug 04, 2006 1:48 am Post subject: Re: ExcelApplication1.Range['A1','J1'].Value Help Syntax err |
|
|
<<Felix A. Hernandez:
Compiles ok, but I get 'OLE error 800A03EC'
That means 'wrong parameter' - my fault, sorry. I haven't
got a machine with ExcelXP on here so I can't check what
parameter the Value property takes. But can you not use
Value2?
--
Deborah Pate (TeamB) http://delphi-jedi.org
TeamB don't see posts sent via Google or ISPs
Use the real Borland server: newsgroups.borland.com
http://www.borland.com/newsgroups/genl_faqs.html |
|
| Back to top |
|
 |
Felix A. Hernandez Guest
|
Posted: Fri Aug 04, 2006 3:08 am Post subject: Re: ExcelApplication1.Range['A1','J1'].Value Help Syntax err |
|
|
Deborah Pate (TeamB) wrote:
| Quote: | Felix A. Hernandez:
Compiles ok, but I get 'OLE error 800A03EC'
That means 'wrong parameter' - my fault, sorry. I haven't
got a machine with ExcelXP on here so I can't check what
parameter the Value property takes. But can you not use
Value2?
|
Yes Value2, works ok. I just wanted to know the parameters. I just cant
find any documentation on these Excel server automation components.
Borlands F1 help documentation, does not find any entries. I tried
looking in my office directory for VBAXL10.chm and no luck. |
|
| Back to top |
|
 |
Deborah Pate (TeamB) Guest
|
Posted: Fri Aug 04, 2006 4:12 pm Post subject: Re: ExcelApplication1.Range['A1','J1'].Value Help Syntax err |
|
|
<<Felix A. Hernandez:
I tried looking in my office directory for VBAXL10.chm and
no luck.
Check your Office CD - it's not installed by default.
--
Deborah Pate (TeamB) http://delphi-jedi.org
TeamB don't see posts sent via Google or ISPs
Use the real Borland server: newsgroups.borland.com
http://www.borland.com/newsgroups/genl_faqs.html |
|
| Back to top |
|
 |
|
|
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
|
|