0

I'm looking for the way to programatically trigger OneNote synchronization from OneDrive (e.g. VBA, Powershell etc).

The case is the following: 1) I've done some changes on laptop and would like to sync notebook on the tablet. 2) Now I have to open OneNote and click sync button. But I'd like to simply run cmd/bat/ps1 file to sync notebook without opening OneNote application. (Like I synchronize files via robocopy)

Is that possible? If so - could you please provide details how I can do it? I googled for possible APIs, but haven't found anything relevant :(

Regards, Vitaliy

2 Answers 2

2

Does your tablet have the full version of OneNote installed? if so the COM API, specifically the SyncHierarchy method might help?

SyncHierarchy Method

Description

Forces OneNote to sync the specified object with the source file on disk.

Syntax
HRESULT SyncHierarchy ( 
    [in]BSTR bstrHierarchyID);
Parameters

bstrHierarchyID—The OneNote ID of the object to be synced.
Sign up to request clarification or add additional context in comments.

2 Comments

Yes. tablet is Surface. And, yes, I saw this method before and thought it might help. But as far as I understand this now - it is about to force store (or flush) changes done programatically to the file (e.g. add/update pages in memory on "object"). So, it doesn't help...
This is the API you are looking for. It will synchronize the requested hierarchy node with the server, which will both upload the local pending changes and download any changes on the server.
0

The OneNote Service API only provides the ability to CREATE PAGES in the Quick Notes section of your default notebook. We are working on getting the api to be able to RECALL pages as well.

I do not think this would still address your need above. In step 1) above when you make "Changes" on your laptop, you are in some OneNote client anyway right? Why would you need to exit the client and do the sync outside it? Clients are pretty fast in syncing content to OneDrive.

2 Comments

Yes, I think you are right - REST API doesn't solve this. As for your question - as a matter of fact, OneNote is not always open on my tableе. When I made some changes on the laptop, on my tablet I have to: 1) open OneNote 2a) wait for some time until it syncs - 2b) trigger update manually (do several clicks). Instead of it - I'd prefer to have some shortcut to run the cmd/ps1 file that can do it w/o opening OneNote. Especially, sometimes is appears that OneNote hasn't completely synchronized and a few important pages were not loaded :(
Question: Why not to provide such API/command line arguments? I.e. to force sync OneNote data

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.