How can we improve the OneNote APIs and developer platform? Vote for an existing idea or share a new one.

Add VBA as a Macro Language for OneNote Desktop

I would find it useful to write VBA to automate certain tasks without using OneNote API. I know VBA and could interoperate Office applications easily if VBA could automate OneNote. I do not know the OneNote API; learning it would be a significant learning curve. Why should OneNote be any different than the rest of the Office offerings?

9 votes
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    Donald shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

    5 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      Submitting...
      • madscijr commented  ·   ·  Flag as inappropriate

        Not only should Microsoft include a VBA editor for OneNote, they should include a Macro Recorder (like Word and Excel have) as well. In fact, they should have Macro Recorder for *all* their products, including Windows itself (and Windows phone, which will give that platform an advantage over iOS and Android).

      • madscijr commented  ·   ·  Flag as inappropriate

        I completely agree. Come on, Microsoft! If you want to be #1, then keep doing what has made you great all along with Office.

      • Andrew Wynn commented  ·   ·  Flag as inappropriate

        I think that rather than write a full suite of code to parse the bits of XML that are returned by the API functions, so we can identify Notebook/SectionGroup/Section/Page then retrieve some data, (because as far as I can see, there is no API function that allows us to change data. The closest thing I can see is CreatePage. No Idea where CreateSection, Notebook, SectionGroup are though) we should just be able to load the VBE and write some code quickly, like in other office applications.

        I came across this post because I have a printout with 50 pages, and I have what they should be called in an excel document. This should be as simple as:
        Dim ONpage as OneNote.Page
        Dim ONsec as OneNote.Section
        Dim i as Long
        i=0
        For each ONPage in ONSec
        i=i+1
        ONPage.Title = Range("A" & i).value
        next ONPage

        Admittedly, that's bad code, but you get the idea. This should be a simple API, or there should be a VBA editor attached to OneNote.

        Additionally, the examples on Microsoft's own website don't work with OneNote 2016, unless the notebook was created in OneNote 2016 (something about a problem with the namespace in the XML)

      Feedback and Knowledge Base