Created
May 27, 2023 07:21
-
-
Save espio999/93fd5777804176ed38d0c91caee8222c to your computer and use it in GitHub Desktop.
Export OneNote item as docx file and convert it to markdown with pandoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$OneNote = New-Object -ComObject OneNote.Application | |
Add-Type -assembly Microsoft.Office.Interop.OneNote | |
$target_id = "{A969C2B3-B790-0EDD-2E5A-9D834611888C}{1}{E1950583228671326940781911959017434812881141}" | |
$publish_path = "G:\work\onenote\export.docx" | |
$pandoc_path = "p:\myapp\pandoc-3.1.2" | |
$markdown_path = "G:\work\onenote\export.md" | |
$OneNote.Publish( | |
$target_id, | |
$publish_path, | |
[Microsoft.Office.InterOp.OneNote.PublishFormat]::pfWord, | |
"") | |
[System.Runtime.InteropServices.Marshal]::ReleaseComObject($OneNote) | Out-Null | |
cd $pandoc_path | |
.\pandoc.exe --from=docx --to=markdown -o $markdown_path $publish_path |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment