ComObjCreate() and "(0x80040154) Class not registered"

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
SAbboushi
Posts: 252
Joined: 08 Dec 2014, 22:13

ComObjCreate() and "(0x80040154) Class not registered"

17 Mar 2021, 11:28

I'm trying to work with TypeLib2AHK and still struggling re: all the moving parts of COM.
At a loss for how to proceed and would appreciate suggestions

Code: Select all

/*
    Been researching 0x80040154 errors; common problems reported include:
      1) COM classes not registered:  I'm finding entries in registry (see screenshot)
        Tried re-registering: "C:\Program Files\Microsoft Office\root\Office16\EXCEL.EXE" /regserver
        
      2) Mismatch in 32 vs 64 bit: I don't think that's my problem:
            Running AHK U64
            Excel is 64-bit
            TypeLib confirms 64-bit:
                "TypeLib
                    {00020819-0000-0000-C000-000000000046}
                        1.9 [PrimaryInteropAssemblyName] = Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71E9BCE111E9429C

                        1.9 [<no name>] = Microsoft Excel 16.0 Object Library
                            0
                                Win64 = C:\Program Files\Microsoft Office\Root\Office16\EXCEL.EXE
                            Flags = 0
                            HelpDir = C:\Program Files\Microsoft Office\Root\Office16\"

      3) Permissions: I don't think that's the problem either:  I'm running as administrator and DCOM permissions for "Microsoft Excel Application" show full access rights

    Ran several captures using PROCMON to compare ComObjCreate() on a COM class that works but that didn't help me figure out the problem.
    
    At a loss for how to proceed and would appreciate suggestions

*/
x := Workbook()

/*
GUID: {00020819-0000-0000-C000-000000000046}
Implements: _Workbook; GUID: {000208DA-0000-0000-C000-000000000046}; Flags: IMPLTYPEFLAG_FDEFAULT
Implements: WorkbookEvents; GUID: {00024412-0000-0000-C000-000000000046}; Flags: IMPLTYPEFLAG_FDEFAULT, IMPLTYPEFLAG_FSOURCE
*/ 
Workbook()
{
	try
	{
		If (impl:=ComObjCreate("{00020819-0000-0000-C000-000000000046}","{00024412-0000-0000-C000-000000000046}"))
			return impl  ; "(0x80040154) Class not registered"

		throw "WorkbookEvents Interface failed to initialize."
	}
	catch e
		MsgBox( e.Message )
}
image.png
image.png (58.79 KiB) Viewed 1090 times
iPhilip
Posts: 827
Joined: 02 Oct 2013, 12:21

Re: ComObjCreate() and "(0x80040154) Class not registered"

17 Mar 2021, 13:45

Does this link help? Searching for 00020819-0000-0000-C000-000000000046 yields a number of similar results.
Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)
SAbboushi
Posts: 252
Joined: 08 Dec 2014, 22:13

Re: ComObjCreate() and "(0x80040154) Class not registered"

18 Mar 2021, 19:40

Thanks for your post. Understanding that I can open a workbook using the Application object (like in the link you posted), I'm unclear on what the obstacles are to using the Workbook object. It is defined within a TypeLib, so my (noob) understanding is that I should be able to instantiate that COM class (or, more accurately, what am I misunderstanding if that's what I think).

From my research, I'm suspecting that the Workbook class is a .NET managed COM class and therefore AHK (unmanaged code) cannot directly communicate with it and requires something like Lexikos' .NET Framework Interop. Can anyone confirm if my suspicion is correct or not?

I found an old article explaining how to examine the PE Header of a PE file (.exe/.dll) to determine whether it is a .NET managed component but the first app I downloaded (ResEdit) that examines PE files only provided superficial info:
image.png
image.png (46.87 KiB) Viewed 1041 times

NOTE: I'm trying to understand AHK and COM; the Excel workbook is merely an example. My instinct tells me it's not that complicated and that maybe if a COM class' registry key only references .NET assemblies (i.e. names like "Microsoft.Office.Interop.Excel" that are referring to a .dll in a .NET assembly folder and DOESN'T have an InprocServer32 or LocalServer32 reference to a .dll or .exe file) that it's likely a .NET managed component... but maybe it's not that simple: I'm thinking that relying on the registry is less than bulletproof e.g. maybe the component isn't registered properly...?
image.png
image.png (139.68 KiB) Viewed 1041 times

But then I'm reading that .NET assemblies aren't registered (they use manifests instead of the registry), so now I don't know what to think when I look at the registry screenshots...

Can anyone help me make better sense of this? Thanks-
iPhilip
Posts: 827
Joined: 02 Oct 2013, 12:21

Re: ComObjCreate() and "(0x80040154) Class not registered"

18 Mar 2021, 20:21

SAbboushi wrote:
18 Mar 2021, 19:40
... I'm trying to understand AHK and COM; the Excel workbook is merely an example.
I have been studying COM for sometime. I found the following tutorial useful as a starting point.

If you want to interact with Excel workbooks I recommend kon's tutorial.
SAbboushi wrote:
18 Mar 2021, 19:40
My instinct tells me it's not that complicated ... but maybe it's not that simple
I haven't found it simple ... but I am learning a lot. Here is a recent result from my learning.

Good luck on your COM adventure. :)

- iPhilip
Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)
SAbboushi
Posts: 252
Joined: 08 Dec 2014, 22:13

Re: ComObjCreate() and "(0x80040154) Class not registered"

19 Mar 2021, 07:18

Thanks iPhilip for your posts. I've got a ways to go before I can create a function like your NewItem() -- but hoping to get there.

Anyone else have any thoughts/feedback on my previous post?

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: avernikov and 111 guests