获取Excel对象的时候出现接口转换失败的错误解决方案

85 次浏览

The registry key mentioned in the exception is IMPORTANT. Take note of that. My issue was with {000208D5-0000-0000-C000-000000000046} hence in putting that down in the solution. Replace the registry below with the one mentioned in the Excel exception.
(fyi, i got the wordings for the solution here, but for a different context: FAQs COM Errors · phw198/OutlookGoogleCalendarSync Wiki · GitHub 26)

Part 1: Fix the Interface
a. Access the Windows Registry Editor via Start>Run>Type Cmd and Enter > Type RegEdt32 and Enter .
b. Navigate to the key that exist (depends on if using the 32 or 64 bit version of Outlook/Windows):

  • HKEY_CLASSES_ROOT\Interface\{000208D5-0000-0000-C000-000000000046}\TypeLib
    (the solution in github uses something different, but I found mine here)

Take note of the version number AND the value that is stated on the right hand section. In my case it is {00020813-0000-0000-C000-000000000046} and Version 1.9

 

Part 2: Fix the TypeLib
a. Navigate to HKEY_CLASSES_ROOT\TypeLib\{00020813-0000-0000-C000-000000000046}
(if yours isn’t {00020813-0000-0000-C000-000000000046}, replace with whichever value is found in part 1)
b. Delete the version keys for any version of that is not installed on your system. You should KEEP THE VERSION that matches part 1. In this case, I’m keeping 1.9 and deleting ANY OTHER values, if there are any. Please please please be careful when deleting things here

c. Make sure that the registry key value ending with EXCEL.EXE is pointing to a valid file location. The key location should be something like HKEY_CLASSES_ROOT\TypeLib\{00020813-0000-0000-C000-000000000046}\1.9\0\Win64

 

Take note of the EXCEL.EXE path, you’ll use it later.

Part 3: Ensure ‘EXCEL.EXE’ is Registered
We now need to make sure that file is properly registered.
a. Download regtlibv12.exe 102 to your computer
b. Go the Windows Start Menu and type cmd .
c. In the search results, right-click cmd.exe and select Run as Administrator...
d. Change directory to where you downloaded regtlibv12.exe , eg: cd %USERPROFILE%\Downloads
e. Execute the following command, where <EXCEL.EXE> is the value taken from part 2:
regtlibv12.exe "<EXCEL.EXE file>" .
For example:
regtlibv12.exe "C:\Program Files\Microsoft Office\Root\Office16\EXCEL.EXE"

购买过VSTO火箭速成班的同学请私聊我远程协助解决

课程购买方式

郑广学VSTO课程云课堂网址
登陆后可免费试学前3节
淘宝下单地址(支持花呗)