I'm trying to select the "used range". I get the worksheet's UsedRange, then I invoke the Select function on it. I receive HRESULT 0x800a03ec on the select call.
Here's the code:
COleVariant result;
HRESULT hr = AutoWrap(DISPATCH_METHOD, &result, irange, L"Select", 0);
I won't bother posting the code for the AutoWrap function (unless someone asks). It's pretty well-known and I haven't modified it.
I'm pretty sure that irange is good, because I tried some calls on it to verify that it has what I expect, and it does. If I iterate through it, I can see the content of each cell (and it's correct); the number of rows and columns returned is correct, and the "Address" property returned checks out.
Worksheet is not locked.
I've seen other problems posted having to do with Locale, and my system is set to U.S. English as is my user account. Neither has been changed.
Hope someone can help!
Update: I have also tried
hr = iRange->Select(vResult);
This does return S_OK, but it does not select the range. Normally, I can't directly call the functions in the iRange struct; the result is a gpf or access violation -- so I have to use the autowrap function (to drive an Invoke call). I'm not surprised this call doesn't work.
I have also tried opening the excel file in non-ReadOnly mode, in case I was locked. This didn't fix the problem. I can select individual cells by getting a single item (cell) from the range, and calling its Select, but I can't select the range.