stephengrice/onenote-to-markdown

Unable to find type [Microsoft.Office.InterOp.OneNote.HierarchyScope].

dakota-white69 opened this issue · 5 comments

Hello Using powershell7 with onenote for windows 10 and am receiving the following error (see below). I have set my policy to unrestricted and installed python3 and Pandoc , my os is Win10 pro

InvalidOperation: C:\Users\username\onenote-to-markdown\convert3.ps1:9
Line |
9 | … erarchy("", [Microsoft.Office.InterOp.OneNote.HierarchyScope]::hsPage …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Unable to find type [Microsoft.Office.InterOp.OneNote.HierarchyScope].

Thank you

Hi, I've run into this error too on some computers. I'm not sure how to fix it. It seems to have something to do with the versions of Office and OneNote that are installed.
I would recommend using the Python script (convert.py) if you can.

Hello. One possibility may be the version of PowerShell.

In my case, running on PSVersion 5.1.22621.963 is ok, but 7.3.4 is not.

Although Windows Terminal provides PowerShell, its default version is 7.3.4. Manually load "Windows PowerShell" or "Developer PowerShell" (their version is 5.1...) there and run the script. It may work.

bad

good

Hello. One possibility may be the version of PowerShell.

In my case, running on PSVersion 5.1.22621.963 is ok, but 7.3.4 is not.

Although Windows Terminal provides PowerShell, its default version is 7.3.4. Manually load "Windows PowerShell" or "Developer PowerShell" (their version is 5.1...) there and run the script. It may work.

bad

good

That's helped. Thanks

You're welcome.

Handling OneNote with PowerShell is a little tricky as
-difference of OneNote and PowerShell,
-running script and OneNote by a common user,
-running script during running OneNote,

Here is the details.

https://impsbl.hatenablog.jp/entry/OneNoteAndPowerShell_en

Hey thanks for commenting on this. I'm moving this issue over to the PageKey GitLab: https://gitlab.com/pagekey/edu/onenote-to-markdown/-/issues/1

It looks like this has been resolved, but I'll try to add some documentation or something before it gets closed out.