-1

I have an Excel add-in firing an HRESULT 0x800401A8 error, when calling the getter of Worksheet.Parent.

I would be glad if anyone could let me know what the error might be, but more importantly and more generally, I would like to know how I can understand these HResult codes?

I did the following but am still confused:

Ama
  • 1,373
  • 10
  • 24
  • You have two questions, here, which are not really compatible... If you want help with trouble-shooting the actual behavior you need to include a [mcve]. It can also help to set up VBA code for the problem environment - if there's also an error in VBA the error message might be more useful than what's being returned to VSTO... – Cindy Meister Feb 24 '20 at 10:14
  • Hi Cindy, I provided context as to why I am asking the main question, which is debugging HResult Code*s*. I was hoping quoting that HResult code which is currently bothering me would provide a base to illustrate how HResult errors are typically troubleshot. I don't know if you are behind the negative vote, but I do not believe my question falls into the "does not show any research effort, is unclear, or not useful" category. – Ama Feb 25 '20 at 10:07

2 Answers2

1

I don't think understanding the structure will help you much.

The most basic information is that

  • success is indicated by S_OK = 0
  • success may also be indicated by S_FALSE = 1
  • all negative numbers are errors

There is an "Error Lookup" tool from Microsoft, which is still in the Visual Studio Tools menu, but it looks like it hasn't been updated for about 20 years.

enter image description here

Honestly, the best way to find details is to google the hex number, or to search directly in Stack Overflow.


Edit

For me, the command is in the tools menu

enter image description here

This may be related to the options that I selected in the Visual Studio Installer. Among several other options, I have selected the workload "Desktop development in C++".

It looks like you can download it here:

https://www.microsoft.com/en-us/download/details.aspx?id=100432

but I have not tried out that link.

Phil Jollans
  • 3,605
  • 2
  • 37
  • 50
  • Where do I find S_OK and S_FALSE? Where do I find the Error Lookup tool in VS 2019? I could not find it and all google returns is a Command Line tool, not quite similar to your screenshot. For example: https://www.microsoft.com/en-us/download/details.aspx?id=100432 – Ama Feb 24 '20 at 16:10
  • Indeed I only see "External Tools..." in this sub-menu. I'll try to add "Desktop development in C++" and revert back to you. Thanks! – Ama Feb 25 '20 at 09:58
-1

Worksheet doesn't actually have parent and you can't access nor inherit worksheet class tho you can extend it.

  • 1
    Hi Mario. What do you mean by "Worksheet does not have a parent"? I have been doing this for years: the parent of a worksheet should return an object which can be cast as a Workbook. The line throwing the error is part of a framework we have been using for the last 10 months with no errors during testing nor production. The current error only appears with one of our clients. – Ama Feb 21 '20 at 09:34