Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default Problem with "For each" loop using .NET Interop and Excel

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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
change "true" and "false" to "availble" and "out of stock" inthestands Excel Worksheet Functions 2 July 19th 07 07:05 PM
problem with Linking workbooks via "copy" and "paste link" Arkitek Excel Discussion (Misc queries) 0 December 19th 06 10:03 PM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM


All times are GMT +1. The time now is 08:54 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"