none
Deleting OneNote programs RRS feed

  • Question

  • Hello

    Does anyone know how I write a program (in VB(A).net) to delete all these created files at once after a OneNote course?

    Now we first have to delete all the files separately but they have told me that this can be done much easier by clicking single or just one button, I should figure out how but I have no idea how to do this.

    Thanks in advance for the help
    Tuesday, March 3, 2020 9:52 AM

All replies

  • Hello,

    To work with OneNote you will need to learn the Graph API which is restful endpoints which is not VBA, VB.NET specific. Microsoft's intent is to allow cross platform access to OneNote which is why not much is done in desktop programming languages.

    Examples of delete calls which are HTTP request.

    DELETE /me/onenote/pages/{id}
    DELETE /users/{id | userPrincipalName}/onenote/pages/{id}
    DELETE /groups/{id}/onenote/pages/{id}
    DELETE /sites/{id}/onenote/pages/{id}

    The majority of code samples are in script languages such as JavaScript and TypeScript, none in VB languages, some in C#.

    https://github.com/OneNoteDev

    Which means you are going to need to translate from those languages to VB languages. I've worked with B2B graphs in C# were the graphs work the same as OneNote but only in ASP.NET/C# so I have nothing to offer for VB other then to say dig in and see if you can translate to VB/desktop solution.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Tuesday, March 3, 2020 11:30 AM
    Moderator
  • Hello

    So there isn't really a possibility to write a program of my own (possibly in C#) in which I can empty OneNote all at once?

    Thanks for the help!

    Wednesday, March 4, 2020 12:30 PM
  • Hello

    So there isn't really a possibility to write a program of my own (possibly in C#) in which I can empty OneNote all at once?

    Thanks for the help!

    C# can work with a restful graph which is the base for OneNote.

    Code from https://docs.microsoft.com/en-us/graph/api/page-delete?view=graph-rest-1.0&tabs=csharp

    GraphServiceClient graphClient = new GraphServiceClient( authProvider );
    
    await graphClient.Me.Onenote.Pages["{id}"]
    	.Request()
    	.DeleteAsync();
    When looking at the API, some code samples have C# and other languages and in some cases only the HTML request. For instance delete contact is pure REST.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Friday, March 6, 2020 2:45 PM
    Moderator