Excel Add-In for OneNote

Build 21.0.8011

Updating Data

After Connecting from VBA, you are ready to update OneNote from macros. The following sections show how to execute parameterized queries to update data. See Executing Parameterized Queries for a complete macro.


Call the Insert method to execute SQL INSERT statements.
public bool Insert(string queryString, object paramNames, object paramValues)

The Insert method returns a boolean indicating the success or failure of the statement execution and accepts the following parameters:

queryStringThe query to execute; for example, INSERT INTO Notebooks (notebook_displayName) VALUES ('Zenburger')
paramNamesAn array with the named parameters used in the query. Required if using a parameterized query.
paramValuesAn array with the values that correspond to the parameter names. Required if using a parameterized query.

The following example inserts the values specified in the parameter arrays and displays a message box indicating the success or failure of the insert.

Dim nameArray
nameArray = Array("notebook_displayName", "Id")
Dim valueArray
valueArray = Array("Town Hall Grille", "Jq74mCczmFXk1tC10GB")
Dim module As New ExcelComModule
module.SetProviderName ("OneNote")
module.SetConnectionString ("OAuthClientId=MyApplicationId;OAuthClientSecret=MySecretKey;CallbackURL=http://localhost:33333;")
Query = "INSERT INTO Notebooks (notebook_displayName, Id) VALUES (@notebook_displayName, @Id)"
If module.Insert(Query, nameArray, valueArray) Then
  MsgBox "The insert was successful."
  MsgBox "The insert failed."
End If

Copyright (c) 2021 CData Software, Inc. - All rights reserved.
Build 21.0.8011