OLE Error: -2147221005 - Invalid class string

I have an app that uses the MS Office plugin to automate Word. At my client it runs fine on Windows 7 but not Windows 10 - get the error above. Same version of Word on each computer (2016 Home & Office).

On my (virtual) Windows 10 system it runs fine as well, but I have Office 365, not Home & Office 2016. Is there some DLL that is needed to make this work on those machines?

32/64 bit mismatch between office DLL and your app?

I compiled it as both 32 and 64-bit but get the same error.

Hi Jay,

I have been using the plugin for many years and haven’t seen this problem…yet. I haven’t been looking for it and it may be an issue. Could you provide a simple program or a snippet of code that shows the issue where you get this error?

Thanks :slight_smile:

[quote=414475:@Jay Madren]I have an app that uses the MS Office plugin to automate Word. At my client it runs fine on Windows 7 but not Windows 10 - get the error above. Same version of Word on each computer (2016 Home & Office).

On my (virtual) Windows 10 system it runs fine as well, but I have Office 365, not Home & Office 2016. Is there some DLL that is needed to make this work on those machines?[/quote]

On that machine this would suggest that for some odd reason the Word OLE object is not accessible. You can test this by this one liner in the open event of a new desktop app:

dim o as new OLEObject("Word.Application")

I suspect you’ll get the same error. Now the question is why isn’t it accessible? Can this user actually run Word under their login?

Try giving your app elevation (admin rights, right click run as admin), this could be a UAC issue.

Is that doesnt work try to narrow down the call that causes the issue and see if that exists in the registry. If not, find which file it is and regsvr32 it. Failing all that, reinstall word on that machine.

Hmm interesting reading into it, it can also happen the other way around too, so if you are already elevating and its causing you issues, try not elevating. The reasoning is here https://msdn.microsoft.com/en-us/library/bb756926.aspx so I guess it could happen if they install Office as a user then you try to run an elevated app using the com components that are registered as a user.

Of course it might be some completely different reason :wink:

A 64 bit app won’t load a 32 bit OLE object and vice versa. That’s the only other reason I can think of.

[quote=414610:@Jason Parsley]On that machine this would suggest that for some odd reason the Word OLE object is not accessible. You can test this by this one liner in the open event of a new desktop app:

dim o as new OLEObject(“Word.Application”)
I suspect you’ll get the same error. Now the question is why isn’t it accessible? Can this user actually run Word under their login?[/quote]
I know it’s the instantiating of the Word OLE object that throws the error. But Word runs fine.

I went onsite today to investigate more thoroughly (most of the information had been relayed by the customer). Turns out it’s only one computer that does this. All of their other computers (Windows 7 & 10) run the app without issue. As far as 32/64-bit, all are 64-bit Windows running the same version of 32-bit Office. And as I stated earlier, I tried compiling the app for both 32-bit and 64-bit but the result is the same.

So, I’m baffled why OLE won’t load in my app on this one computer. I couldn’t find anything different on it versus the other computers. I tried doing a full repair of Office, which essentially uninstalls Office then downloads a new copy and installs that. No difference. I also tried running it elevated - still same result.

One interesting tidbit - this is one of their newest computers. But another one purchased at the same time works correctly.

Anyone know of an OLE diagnostic utility or troubleshooter?

Do macros run for Word?

Interesting, here’s a few more things to try.

First off, run regedit and search for “word.application” without the quotes. That should find something in Computer\HKEY_CLASSES_ROOT\CLSID

Option 1

Try a build where you call the CLSID directly to see if its actually installed correctly (if the CLSID is different from the one above, use the one above:

Dim o As New OLEObject(“000209FF-0000-0000-C000-000000000046”)

If things work then there’s missing registry entries, I’d try a fully uninstall of office, reboot and reinstall rather than a repair.

Option 2

Apparently it can be caused by installing Office using the Click-to-Run method rather than using the traditional installer.

The easiest way to check if this is on the system is to check Services to see if there’s one called Microsoft Office ClickToRun Service.

https://windowsreport.com/uninstall-office-click-to-run/

Option 3

Failing that follow these steps to clean things up then reinstall.

https://windowsreport.com/fix-couldnt-repair-office/

Option 4

Failing that reinstall windows as something is broken.

Thanks Julian. I’ll try these suggestions when I can get by there again next week. I can tell you that all of their computers use Click-to-Run. They’re all Dell machines that are ordered with Office.