 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Bogdan X Guest
|
Posted: Wed Dec 15, 2004 5:14 am Post subject: Excel - OnSheetSelectionChange problem |
|
|
I'm using Delphi 7 with the ExcelApplication server component and I'm trying
to catch the OnSheetSelectionChange event - all is ok but I can't get the
name of the returned range. In Delphi 5 I'd use Sh.Address to get "$B$2",
but it doesn't work anymore (I've understood that Delphi 5 had a problem
with var params in events, Delphi 6 had another one and it was finally fixed
in D7). Also MSDN seems to confirm there is no param needed for
Target.Address
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbaxl11/html/xlevtSheetSelectionChange1.asp)
Here is the code:
procedure TForm1.exaSheetSelectionChange(ASender: TObject;
const Sh: IDispatch; const Target: ExcelRange);
begin
// Caption := Sh.Address; - this worked in D5 but doesn't work anymore in
D7
Memo1.Lines.Add('newly selected range: ' + Target.Address); //this gets
the '[' expected but ';' found error message; what parameters should I send?
// also, using Sh.Address gives "Undeclared identifier" or the same error
if I typecast to ExcelRange
end;
Thanks in advance for your help
|
|
| Back to top |
|
 |
Mariusz Celmer Guest
|
Posted: Wed Dec 15, 2004 8:54 am Post subject: Re: Excel - OnSheetSelectionChange problem |
|
|
Hi,
take a look at Excel Range.Address property help. There are few parameters
but they seems to be optional. When I work with Excel in OLE they were not
needed, but when I use Excel type library I have to pass them. Maybe using
ExcelApplication server you need to pass them also:
try something like this:
ARange.Address[TRUE, TRUE, xlA1, FALSE, EmptyParam];
there is as follows in MicrosoftVB help:
RowAbsolute Optional Variant. True to return the row part of the reference
as an absolute reference. The default value is True.
ColumnAbsolute Optional Variant. True to return the column part of the
reference as an absolute reference. The default value is True.
ReferenceStyle Optional XlReferenceStyle.
XlReferenceStyle can be one of these XlReferenceStyle constants.
xlA1 default. Use xlA1 to return an A1-style reference.
xlR1C1. Use xlR1C1 to return an R1C1-style reference.
External Optional Variant. True to return an external reference. False to
return a local reference. The default value is False.
RelativeTo Optional Variant. If RowAbsolute and ColumnAbsolute are False,
and ReferenceStyle is xlR1C1, you must include a starting point for the
relative reference. This argument is a Range object that defines the
starting point.
hth,
Mariusz
"Bogdan X" <madexcept (AT) hotpop (DOT) com> wrote
| Quote: | I'm using Delphi 7 with the ExcelApplication server component and I'm
trying
to catch the OnSheetSelectionChange event - all is ok but I can't get the
name of the returned range. In Delphi 5 I'd use Sh.Address to get "$B$2",
but it doesn't work anymore (I've understood that Delphi 5 had a problem
with var params in events, Delphi 6 had another one and it was finally
fixed
in D7). Also MSDN seems to confirm there is no param needed for
Target.Address
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbaxl11/ht |
ml/xlevtSheetSelectionChange1.asp)
| Quote: |
Here is the code:
procedure TForm1.exaSheetSelectionChange(ASender: TObject;
const Sh: IDispatch; const Target: ExcelRange);
begin
// Caption := Sh.Address; - this worked in D5 but doesn't work anymore
in
D7
Memo1.Lines.Add('newly selected range: ' + Target.Address); //this gets
the '[' expected but ';' found error message; what parameters should I
send?
// also, using Sh.Address gives "Undeclared identifier" or the same
error
if I typecast to ExcelRange
end;
Thanks in advance for your help
|
|
|
| Back to top |
|
 |
Bogdan X Guest
|
Posted: Wed Dec 15, 2004 1:19 pm Post subject: Re: Excel - OnSheetSelectionChange problem |
|
|
Thanks for your help - I was just going to post the solution I had
found, but yours is more elegant (I was using Target.Address[...]
with variables and 0 instead of EmptyParam).
Does anybody know why using the server components requires
stuff like this?
"Mariusz Celmer" <Mariusz.Celmer (AT) poczta (DOT) neostrada.pl> wrote
| Quote: | Hi,
take a look at Excel Range.Address property help. There are few parameters
but they seems to be optional. When I work with Excel in OLE they were not
needed, but when I use Excel type library I have to pass them. Maybe using
ExcelApplication server you need to pass them also:
try something like this:
ARange.Address[TRUE, TRUE, xlA1, FALSE, EmptyParam];
there is as follows in MicrosoftVB help:
RowAbsolute Optional Variant. True to return the row part of the
reference
as an absolute reference. The default value is True.
ColumnAbsolute Optional Variant. True to return the column part of the
reference as an absolute reference. The default value is True.
ReferenceStyle Optional XlReferenceStyle.
XlReferenceStyle can be one of these XlReferenceStyle constants.
xlA1 default. Use xlA1 to return an A1-style reference.
xlR1C1. Use xlR1C1 to return an R1C1-style reference.
External Optional Variant. True to return an external reference. False
to
return a local reference. The default value is False.
RelativeTo Optional Variant. If RowAbsolute and ColumnAbsolute are
False,
and ReferenceStyle is xlR1C1, you must include a starting point for the
relative reference. This argument is a Range object that defines the
starting point.
hth,
Mariusz
"Bogdan X" <madexcept (AT) hotpop (DOT) com> wrote in message
news:41bfc84a (AT) newsgroups (DOT) borland.com...
I'm using Delphi 7 with the ExcelApplication server component and I'm
trying
to catch the OnSheetSelectionChange event - all is ok but I can't get the
name of the returned range. In Delphi 5 I'd use Sh.Address to get "$B$2",
but it doesn't work anymore (I've understood that Delphi 5 had a problem
with var params in events, Delphi 6 had another one and it was finally
fixed
in D7). Also MSDN seems to confirm there is no param needed for
Target.Address
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbaxl11/ht
ml/xlevtSheetSelectionChange1.asp)
Here is the code:
procedure TForm1.exaSheetSelectionChange(ASender: TObject;
const Sh: IDispatch; const Target: ExcelRange);
begin
// Caption := Sh.Address; - this worked in D5 but doesn't work anymore
in
D7
Memo1.Lines.Add('newly selected range: ' + Target.Address); //this gets
the '[' expected but ';' found error message; what parameters should I
send?
// also, using Sh.Address gives "Undeclared identifier" or the same
error
if I typecast to ExcelRange
end;
Thanks in advance for your help
|
|
|
| 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
|
|