stephengrice/onenote-to-markdown

Does not work with "OneNote for Windows 10"

travisrecupero opened this issue · 4 comments

Problem

There are two types of OneNote applications a user can have installed on their PC:

  1. OneNote
  2. OneNote for Windows 10

When using "OneNote for Windows 10" and running convert.py, the application will throw the following message !!!Error!!! Hint: Make sure OneNote is open first..

TODO

  • Create some sort of error checking to detect different application types
    • An better solution would be to add functionality for both types of OneNote application types

Could be related to #2

I was running into the same issue. Fixed by running the script and OneNote as the same user i.e. both as admin or both as user ABC.

Stack trace:

Traceback (most recent call last):
File "C:\Python311\Lib\site-packages\win32com\client\dynamic.py", line 86, in _GetGoodDispatch
IDispatch = pythoncom.connect(IDispatch)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pywintypes.com_error: (-2147221021, 'Operation unavailable', None, None)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\inut\Documents\onenote-to-markdown-master\convert.py", line 115, in
onenote = win32.gencache.EnsureDispatch("OneNote.Application.12")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\win32com\client\gencache.py", line 618, in EnsureDispatch
disp = win32com.client.Dispatch(prog_id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\win32com\client_init_.py", line 117, in Dispatch
dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch, userName, clsctx)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\win32com\client\dynamic.py", line 106, in _GetGoodDispatchAndUserName
return (_GetGoodDispatch(IDispatch, clsctx), userName)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\win32com\client\dynamic.py", line 88, in _GetGoodDispatch
IDispatch = pythoncom.CoCreateInstance(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
pywintypes.com_error: (-2146959355, 'Server execution failed', None, None)
!!!Error!!! Hint: Make sure OneNote is open first.

Confirmed this worked for me when I ran script (via Powershell) and OneNote as administrator.

Thanks for all the comments. Closing to an issue on our GitLab: https://gitlab.com/pagekey/edu/onenote-to-markdown/-/issues/2