Open OneNote with sending a local file
I try to "open in" OneNote, directly without passing by the "open in" menu.
I've found the URL-scheme for that. "onenote:URL of local file".
But when I try with onenote:file:///..... As usual, it is refused.
Do I need to write it in another way?
file_loc = 'file.pdf'
file_loc_url = 'onenote:ofv%7Cu%7C' + path2url(os.path.abspath(file_loc))
urlapp = nsurl(file_loc_url)
This code opens onenote which tries to open the file but displays an error telling
"we can't open the link, there is a problem with the link...
cook last edited by
This isn't a pythonista problem, it's more so a OneNote issue in how the app handles stuff coming in via the url scheme. I recall trying this a long while back - trying to get OneNote to open to a specific file. It took some tinkering.
Check out this for some more info and I hope that gives you a bit of direction. But basically OneNote wants more information than just a file or text etc. You need to provide it with where to put that.
I'm not sure that you are right.
I made a Workflow as extension with only one command "Open In" specifying only OneNote and my PDF has been opened directly and correctly.
This I believe there is an easy way to do it with an URL scheme, but some ones say "use file:// instead of file:///", other say "encode you URL", etc..., but I didn't find any guy who did it, except Workflow developer.
omz last edited by
I don't know the specifics of OneNote's URL scheme support, but It's basically not possible for it to do anything with an absolute file path (regardless of how you format it). iOS apps are sandboxed, and OneNote cannot access any files that are in Pythonista's sandbox. The system-provided "Open in" dialog is basically there to make transferring files from one sandbox to another possible, but you can't do it without showing the dialog.
Thanks for your clarification.
But the "Open In" action of Workflow with only one app does not show the "Open In" menu and OneNote starts with its Share window where you choose in which section you want to send the opened/copied file. If you start OneNote via its URL scheme, you don't have this window...
I've asked to the Workflow support how they are able to have a such process.
Wait and see, and, of course I'll transfer their answer in this topic
cook last edited by
If you don't get an answer, and all you want to do is add a PDF to somewhere on OneNote from Pythonista... you could try the OneNote API.
Of course it may not be AS fast...but you could pull a list of sections from the API and choose which one you want with a UI list dialogue or tableview in Pythonista.
Thanks to help me to find a solution.
I think that using an API is to complex for me 😅 and I only want to fall in the first window of the "Open In" OneNote in which you choose where to copy your file, exactly like with Workflow. I have to say that before buying Phthonista, I wrote some workflows and since I bought it, I've rewritten all of them in Pythonista and I don't use Workflow any more, even if I'm no more a good developer (I'm retired for 6 years),
JonB last edited by
Pretty sure Workflow uses the API, not the url scheme.
cvp last edited by cvp
Answer from Workflow support:
**I can't speak exactly to how right now, but if you're trying to send a file via the URL scheme, that will not complete. Open In is a system feature, separate from URL schemes, which deal primarily with text and/or the clipboard.
This we are now sure that they don't use URL-scheme (like @jonB idea), I have "insisted" to get an explanation.
JonB last edited by
Really too complex for me and estonished I should have to login, what is not asked by Workflow. I don't want to open a page and write in it, but only to "open in" OneNote without passing by the standard Open In menu where I could choose OneNote.
Found this : http://www.mattrayls.com/2015/06/10/sharing-an-image-with-instagram-through-uidocumentinteractioncontroller-swift/
Could I get some help to convert in Python?
Thanks by advance