Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Open OneNote with sending a local file
-
-
file_loc = 'file.pdf'
file_loc_url = 'onenote:ofv%7Cu%7C' + path2url(os.path.abspath(file_loc))
app=UIApplication.sharedApplication()
urlapp = nsurl(file_loc_url)
app.openURL_(urlapp)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... -
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. -
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 -
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), -
Pretty sure Workflow uses the API, not the url scheme.
-
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.
-
-
Thanks.
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