SjoerdV / ConvertOneNote2MarkDown

Ready to make the step to Markdown and saying farewell to your OneNote, EverNote or whatever proprietary note taking tool you are using? Nothing beats clear text, right? Read on!
GNU General Public License v3.0
196 stars 113 forks source link

implicit type conversion not possible (Application2Class => IApplicationCOM) #1

Closed aisbergde closed 4 years ago

aisbergde commented 4 years ago

When I run I get this error

Enter the (preferably empty!) folder path (without trailing backslash!) that will contain your resulting Notes structure. ex. 'c:\temp\notes': d:\onenote_2_markdown
Ausnahme beim Aufrufen von "GetHierarchy" mit 3 Argument(en):  "Das COM-Objekt des Typs
"Microsoft.Office.Interop.OneNote.Application2Class" kann nicht in den Schnittstellentyp
"Microsoft.Office.Interop.OneNote.IApplicationCOM" umgewandelt werden. Dieser Vorgang konnte nicht durchgeführt
werden, da der QueryInterface-Aufruf an die COM-Komponente für die Schnittstelle mit der IID
"{452AC71A-B655-4967-A208-A4CC39DD7949}" aufgrund des folgenden Fehlers nicht durchgeführt werden konnte: Bibliothek
nicht registriert. (Ausnahme von HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED))."
In D:\Repos\GitHub\ConvertOneNote2MarkDown\ConvertOneNote2MarkDown.ps1:21 Zeichen:3
+   $OneNote.GetHierarchy("", [Microsoft.Office.InterOp.OneNote.Hierarc ...
+   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : InvalidCastException

Windows 10, OneNote is part of the current Office 365 Or should I try the Windows 10 Version? Or should I search for the 2016 Version?

aisbergde commented 4 years ago

I repaired office, and now it is running, but I get a lot of errors. I will wait it to finish and then I will see. What I see is, something is generated in the target folder.

aisbergde commented 4 years ago

folders are created, but they are empty. And these are the errors:

#### Urlaubsplus | Suche
Error while publishing file 'Urlaubsplus | Suche' to docx: Ausnahme beim Aufrufen von "Publish" mit 4 Argument(en):  "Der RPC-Server ist nicht verfügbar. (Ausnahme von HRESULT: 0x800706BA)"
pandoc.exe: d:\onenote_2_markdown\Urlaub\Urlaub_2020_Winter_Malta\Urlaubsplus___Suche.docx: openBinaryFile: does not exist (No such file or directory)
Ausnahme beim Aufrufen von "GetPageContent" mit 3 Argument(en):  "Der RPC-Server ist nicht verfügbar. (Ausnahme von
HRESULT: 0x800706BA)"
In D:\Repos\GitHub\ConvertOneNote2MarkDown\ConvertOneNote2MarkDown.ps1:141 Zeichen:15
+               $OneNote.GetPageContent($pageid, [ref]$pagexml, 7)
+               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : COMException

Get-Content : Der Pfad "D:\onenote_2_markdown\Urlaub\Urlaub_2020_Winter_Malta\Urlaubsplus___Suche.md" kann nicht
gefunden werden, da er nicht vorhanden ist.
In D:\Repos\GitHub\ConvertOneNote2MarkDown\ConvertOneNote2MarkDown.ps1:192 Zeichen:19
+ ...           ((Get-Content -path "$($fullexportpathwithoutextension).md" ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (D:\onenote_2_ma...plus___Suche.md:String) [Get-Content], ItemNotFoundEx
   ception
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetContentCommand

Error while renaming image file path references for file 'Urlaubsplus | Suche': Es ist nicht möglich, eine Methode für einen Ausdruck aufzurufen, der den NULL hat.
aisbergde commented 4 years ago

I restarted Windows, restarted OneNote several times and now ti works. it looks like a communication error between powershell and OneNote

SjoerdV commented 4 years ago

Great to see you figured it out! Hope it helps you.

dirkagterhuis commented 4 years ago

Hi @SjoerdV, first of all: wonderful work on creating this, it will definitely release me from my onenote lock-in into the world of markdown notes!

I think I'm running into the same issue as @aisbergde. I'm using Office 365 & Windows 10. When I run the Powershell command, I get the following (I copied the example error log of 1 test notebook page called 'Test', which is output in the terminal):

#### Test
Error while publishing file 'Test' to docx: Exception calling "Publish" with "4" argument(s): "Exception from HRESULT: 0x80042006"
pandoc.exe: ..\poging2\Persoonlijk_(web)\Quick_Notes\Test.docx: openBinaryFile: does not exist (No such file or directory)
Get-Content : Cannot find path 'D:\Onenote Migratie\poging2\Persoonlijk_(web)\Quick_Notes\Test.md' because it does not exist.
At D:\Onenote Migratie\ConvertOneNote2MarkDown\ConvertOneNote2MarkDown.ps1:192 char:19
+ ...           ((Get-Content -path "$($fullexportpathwithoutextension).md" ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (D:\Onenote Migr...k_Notes\Test.md:String) [Get-Content], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetContentCommand

Error while renaming image file path references for file 'Test': You cannot call a method on a null-valued expression.

I think it's to do with the Onenote version. It seems to go wrong in the part where the .docx is created. I believe the error code 0x80042006 belongs to onenote, stating that something can't be found. When I opened onenote, I also didn't see the export option to a .doxc format.

After reinstalling office, I noticed now that the option to export a Onenote page to a .docx file was available, so my hopes were high, but I still got the same error.

Do you have any suggestions?

dirkagterhuis commented 4 years ago

ah, the thing that made a difference: I used "../targetdirectory" when I was asked to provide the target directory, but when I used the full path, it worked. Anyhow, thanks for making this!

SjoerdV commented 4 years ago

Great to hear you got it working and found it a useful script @dirkagterhuis, cheers!