Excel Range.Find(XlSearchDirection.xlPrevious) bug

D

David Thielen

Hi;

If you use the excel file in http://www.windwardreports.com/temp/PrevBug.zip
and then run the following code - it will not find the previous tag but
instead jumps to the first tag in the spread sheet.

This only happens if starting on a cell that has "</wr:" in it. If starting
anywhere else, it works fine.

Any idea why?
Worksheet xxWs = (Worksheet)app.NativeWorkbook.ActiveSheet;
Range xxSelOn = (Range)xxWs.UsedRange.Cells[11, 1];
// get the row on A:N -> selOn:N
Range xxxSearchRange = xxWs.get_Range(xxWs.UsedRange.Cells[xxSelOn.Row,
1], xxSelOn);
// now get the block from A:1 -> "UsedColumns.Count:row-1"
Range xxxFullRows = xxWs.get_Range(xxWs.UsedRange.Cells[1, 1],
xxWs.UsedRange.Cells[xxSelOn.Row - 1, xxWs.UsedRange.Columns.Count]);
xxxSearchRange = app.NativeApplication.Union(xxxSearchRange,
xxxFullRows, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing);
Range xxxStartAfter = (Range)xxWs.UsedRange.Cells[1, 1];
Range xxxRtn = xxxSearchRange.Find("<wr:", xxxStartAfter,
XlFindLookIn.xlValues, XlLookAt.xlPart, XlSearchOrder.xlByRows,
forward ? XlSearchDirection.xlNext : XlSearchDirection.xlPrevious,
false, false,
Type.Missing);

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 
J

Jialiang Ge [MSFT]

Hello Dave,

Based on my test, it seems to be an issue of Excel when *Find(xlPrevious)*
or *FindPrevious* is called on a *union* range. When the search reaches the
beginning of the specified range, it does not wrap around to the end of the
range as documented in
http://msdn2.microsoft.com/en-gb/library/microsoft.office.tools.excel.namedr
ange.findprevious(VS.80).aspx.

I am consulting the product team to see if it is an issue of our product. I
will get back to you as soon as possible. Thank you for your reporting.

Happy New Year!
Regards,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
For MSDN subscribers whose posts are left unanswered, please check this
document: http://blogs.msdn.com/msdnts/pages/postingAlias.aspx

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications. If you are using Outlook Express/Windows Mail, please make sure
you clear the check box "Tools/Options/Read: Get 300 headers at a time" to
see your reply promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
J

Jialiang Ge [MSFT]

Hello,

I am sorry, Dave. The product team has confirmed that it is an issue of
Excel when calling Find on a union of ranges where the united ranges do not
have the same number of columns / rows so that the union range is not
rectangular. The workaround is to call Find on each range separately.
Please have a try and if you encounter any problem, please do let me know.
I will do my best to help.

Happy New Year!
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

=================================================
When responding to posts, please "Reply to Group" via your newsreader
so that others may learn and benefit from your issue.
=================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
J

Jialiang Ge [MSFT]

Hello Dave,

According to the response of the product team, the issue may still exist in
the next version due to the backward compatibility. Sorry for the
inconveniences.

Regards,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

=================================================
When responding to posts, please "Reply to Group" via your newsreader
so that others may learn and benefit from your issue.
=================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top