0x800a03ec when calling Select in an Excel range (IRange). The range was returned from the sheet used by the range
I am trying to select the "used range". I get the UsedRange worksheet, then I call the Select function on it. I am getting HRESULT 0x800a03ec when selecting a call.
Here's the code:
ColeVariant result;
HRESULT hr = AutoWrap (DISPATCH_METHOD, & result, irange, L "Select", 0);
I won't bother posting code for the AutoWrap function (unless someone asks). This is pretty well known and I haven't modified it.
I'm sure iranga is good because I tried several calls to check that it has what I expect and it does. If I repeat it, I can see the contents of each cell (and this is correct); the number of rows and columns returned is correct, and the Address property is returned.
The worksheet is not locked.
I have seen other Locale related issues and my system is set to English, just like my user account. Nothing changed.
Hope someone can help!
Update . I have also tried
hr = iRange->Select(vResult);
This returns S_OK, but does not select a range. I usually cannot directly call functions in the iRange structure; the result is a gpf or an access violation - so I have to use the autowrap function (to trigger the Invoke call). I'm not surprised this call doesn't work.
I also tried to open the excel file in a mode other than ReadOnly in case I am locked. This didn't fix the problem. I can select individual cells by getting one item (cell) from the range and causing it to be selected, but I cannot select the range.
source to share
I found the answer to this question. This only seems to be a problem when used in the DSOFRAMER example (Microsoft KB 311765). DSOFramer is a versatile ActiveX control for embedding MS Office documents. The problem also only occurs in the debug build; release builds are fine.
I also found a workaround that works on release or debug: get any cell in the range (using get_Item), then call select on that item, then select again to deselect. The selection can then be called up in the range. Apparently select cannot be called on a range if there is already a selected cell (or perhaps if the selection state is undefined).
source to share