Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error running script. Com class retreival. #28

Open
Putger opened this issue Dec 29, 2023 · 2 comments
Open

Error running script. Com class retreival. #28

Putger opened this issue Dec 29, 2023 · 2 comments

Comments

@Putger
Copy link

Putger commented Dec 29, 2023

New-Object : Retrieving the COM class factory for component with CLSID {00000000-0000-0000-0000-000000000000} failed
due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
At F:\Downloads\ConvertOneNote2MarkDown-master\ConvertOneNote2MarkDown.ps1:47 char:14

  • $OneNote = New-Object -ComObject OneNote.Application
  •          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : ResourceUnavailable: (:) [New-Object], COMException
    • FullyQualifiedErrorId : NoCOMClassIdentified,Microsoft.PowerShell.Commands.NewObjectCommand

Unable to find type [Microsoft.Office.InterOp.OneNote.HierarchyScope].
At F:\Downloads\ConvertOneNote2MarkDown-master\ConvertOneNote2MarkDown.ps1:50 char:29

  • ... erarchy("", [Microsoft.Office.InterOp.OneNote.HierarchyScope]::hsPage ...
  •             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (Microsoft.Offic....HierarchyScope:TypeName) [], RuntimeException
    • FullyQualifiedErrorId : TypeNotFound

Exception calling "ReleaseComObject" with "1" argument(s): "Object reference not set to an instance of an object."
At F:\Downloads\ConvertOneNote2MarkDown-master\ConvertOneNote2MarkDown.ps1:248 char:3

  • [System.Runtime.Interopservices.Marshal]::ReleaseComObject($OneNote ...
  • + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : NullReferenceException
    
    

Remove-Variable : Cannot find a variable with the name 'OneNote'.
At F:\Downloads\ConvertOneNote2MarkDown-master\ConvertOneNote2MarkDown.ps1:249 char:3

  • Remove-Variable OneNote
  • + CategoryInfo          : ObjectNotFound: (OneNote:String) [Remove-Variable], ItemNotFoundException
    + FullyQualifiedErrorId : VariableNotFound,Microsoft.PowerShell.Commands.RemoveVariableCommand
    
@grumpymaker
Copy link

I ran into this and a few other gotchas. What helped for me:

  • Make sure that OneNote is installed, or the Com automation server won't be able to load it.
  • OneNote MUST be Open and running.
  • Make sure that OneNote and powershell are running in the same security context (e.g. run PowerShell as regular user, not as an administrator if OneNote is not running as an administrator)
  • Make sure that you are using the correct PowerShell architecture as OneNote (e.g. x64 if OneNote x64 is running).
    For me, using just "PowerShell" and not "PowerShell x64" or "PowerShell x86" and not opening as an administrator did the trick.

@gonzofy
Copy link

gonzofy commented Jun 14, 2024

@grumpymaker Thanks for the explanation. I hit the same bug, and it was because I was running the script in an admin terminal vs. a user terminal. Might be worth updating the docs on the homepage?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants