Can't test it here, but try
r = Excel.Selection
instead of just
r = Selection
--
Regards
Juan Pablo González
"Gene Belknap" wrote in message
...
Hi,
When running the following code snippet using
"Microsoft.Office.Interop.Excel" through
VB.NET
dim c as Excel.Range
dim r as Excel.Range
r = Selection
For Each c in r '<-- Fails with "Member not found"
msgbox (c.Address)
Next
"For Each c in r.Cells" also fails with the same error.
In each case, I get the "Member not found" error.
I can use a loop counter successfully. For example
dim i as Integer
for i = 1 to r.cells.count
c = r.cells(i)
msgbox (c.Address)
next
this code works.
The "for each c in r" construct works fine with VBA. The problem is in
porting VBA to .NET. Without the "for each c in r" construct, the port will
be very painful and tedious.
Any reason why the "for each c in r" approach does not work in .NET? Are
there updates/patches that fix this? Am I missing something?
Thanks,
-Gene