OneNote VBA Reference Library w Excel : OneNote Picker

PaulB 1 Reputation point
2022-06-01T02:52:32.517+00:00

@all ,

Trying to use OneNote via the Excel VBA Tools Reference library. I have selected the following libraries :

  • Microsoft OneNote 12.0 Type Library
  • Microsoft OneNote 15.0 Extended Type Library
  • Microsoft OneNote 15.0 Type Library

As an FYI, I work in an organisation that only allows VBA (no C# or MS Graph).
The task I would like to do is to call the OneNote add in in Outlook to bulk copy my emails into a OneNote file.
The projects I run each have a OneNote file with all correspondence (including sent items).

Couldn't for the life of me figure out how to use VBA to call the Outlook OneNote Addin so started using Excel and try the libraries to do that for my.

The below code is my attempt at getting the OneNote picker to run.
Problem is I have no idea on how to use the methods in the OneNote library.

Could someone advise on the following two points (in order)

  1. Is there a way to use VBA to get the Outlook OneNote addin to work?
  2. The following code stumps me on the (pCallback as IQuickFilingDialogCallback), have no idea what a pCallback is).

Also don't think I've got access to GitHub though if there are any samples there will try on my home PC to look through the code.

Sub OneNotePicker()  
  
    Dim onApp As New OneNote.Application  
      
    onApp.QuickFiling.Run(pCallback as IQuickFilingDialogCallback)  
      
End Sub  
Developer technologies Visual Basic for Applications
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. kinuasa 371 Reputation points
    2022-06-02T02:59:41.47+00:00

    Is the following code helpful?

    'Set the locations for notes sent to OneNote in advance.
    '(Open your OneNote, click File tab > Options > Send to OneNote)
    Private Sub OutlookMacroSample()
      Dim itm As Object
      Const CtrlId As String = "MoveToOneNote"
      For Each itm In ActiveExplorer.Selection
        With itm.GetInspector
          .Display
          If .CommandBars.GetEnabledMso(CtrlId) Then .CommandBars.ExecuteMso CtrlId
          .Close olDiscard
        End With
      Next
    End Sub
    

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.