interop >> Help!!!!!! - Find Function not working from C#

by andyblum » Thu, 08 Jun 2006 04:53:28 GMT

I have been enjoying Excel programming but am now hitting a wall. I
simply want to transfer all data from the spreadsheet at runtime. The

spreadsheet is read ever 1 secs on a timer as it has real-time
streaming data inside of it.

I figured the first step was to dynamically figure out a range address
then simply get that range and assign the values to an arraylist.


How do I dynamically figure out a range to do this. The find function
is throwing a COM Interrupt message.


Here is my Find Call


int iMaxRows = excelWorksheet.Cells.Find("*", "A1",
Excel.XlFindLookIn.xlValues, Excel.XlLookAt.xlPart,
Excel.XlSearchOrder.xlByRows, Excel.XlSearchDirection.xlPrevious,
false, false, Type.Missing).Row;


It throws a type mismatch on the third to last argument which is
MatchCase an object.
Ive tried


1. Type.Missing
2. 0
3. Declare object var = false and use var


None of it works. Any Suggestions?????


Thank You in advance for reading and hopefully solving.


interop >> Help!!!!!! - Find Function not working from C#

by shumaker » Thu, 08 Jun 2006 06:39:51 GMT


Maybe try False or FALSE, just a wild guess.

interop >> Help!!!!!! - Find Function not working from C#

by andyblum » Thu, 08 Jun 2006 06:48:37 GMT

Thanks,

But False or FALSE are not valid C# objects.

Andy

interop >> Help!!!!!! - Find Function not working from C#

by Joachim Van den Bogaert » Thu, 08 Jun 2006 15:44:43 GMT

> I have been enjoying Excel programming but am now hitting a wall.

You'll hit it more often than you'll like ;-)


If you want to get all data in an excel sheet, don't use the find
function,
use the Worksheet.UsedRange property instead. It will give you the
range of all cells that either contain something or have a non-default
layout.
This means that you'll also select empty cells, but it's a good start
since you'll like to check cell contents anyway before you start doing
things. Besides, it is the only method I've heard of,

cheers,
Joachim

interop >> Help!!!!!! - Find Function not working from C#

by andyblum » Tue, 13 Jun 2006 02:17:28 GMT

Just posting my solution for future developers to use. THis code works
perfectly and is different then any one described so far.

Excel.Range workingRangeCells = excelWorksheet.get_Range("A1",
Type.Missing);
workingRangeCells =
workingRangeCells.get_End(Excel.XlDirection.xlToRight);
workingRangeCells =
workingRangeCells.get_End(Excel.XlDirection.xlDown);
string downaddress = workingRangeCells.get_Address(false, false,
Excel.XlReferenceStyle.xlA1, Type.Missing, Type.Missing);
workingRangeCells = excelWorksheet.get_Range("A1", downaddress);

Andy Blum

Similar Threads

1. Help Nodes Contains function not working ???

Dear all,

I am populating a treeview control with an XML file.
I need to skip duplicate node entry from XML file in treeview if exit

For that I ma using the following line of code :

     If NodeCollection.Contains(node) Then Return True

That function always return false.
If I go through nodeCollection object and check if my Node object exist I 
can saee it already in the collection.

Why the Contains return always false ?
Waht is the criteria that identify an existing node iunn the collection, is 
it ist name?

Thnaks for helping me how to identify an exiting node
regards
serge

2. Javascript function works but C# function doesn't execute - Asp.Net

3. API function not working in .NET (works well in VB 6)

Hi All,

.NET application does not give correct result when I used following API
function .

{
Declare Function waveInGetNumDevs Lib "winmm.dll" () As Long

MsgBox(waveInGetNumDevs)

}

.NET gives it as 855400533......

VB6 gives it 1
VC++6 gives it 1

So why .NET is not giving correct one.

Thanks in advance

Sakharam Phapale


4. [HTML Help] 'HelpNavigator.Find' doesn't work in 'Help' &/or 'HelpProvider' classes - .NET Windows Forms

5. HELP: C# - ListBox.SetSelected Not Working Properly!

I'm having a major problem with a databound listbox in C#.  In the
constructor for the form I am trying to pre-select some of the items based
in information in the database. When I step through the debugger it all
seems to be working properly until the Load function is called, and then all
my selections but 1 are unselected.  Anybody had any experience with this
and know of a fix?

Listbox is databound
Listbox appears on a tabpage inside a tabcontrol, inside a form
SetSelected works in contructor
All but one item unselected at beginning of load

Thanks for any help,
Andrew


6. Repainting a Control not working help C#!!!! - CSharp/C#

7. VS2005: F1 online help does not work within 'aspx.cs' files

8. not sure why close window function not working - Asp.Net