Using VBA to access 'SendToOneNote' Outlook Addin Command

Paul B 1 Reputation point
2022-06-26T12:17:01.783+00:00

Would like to use Excel to control Outlook via VBA (which I can do).
The part I cannot do is after selecting all contents of an Outlook folder, access the 'Send to One Note' button in Outlook.

Attached are some screen shots, and below is some helpful code provided, however it goes through the selected items in a folder one by one (as objects). I would like to send the lot all at once.

Anyone know how to modify the code below, so that all selected items in an Outlook folder will move to a chosen OneNote location.

Private Sub OutlookMacroSample()  
      
    Dim olApp As New Outlook.Application  
    Dim olNS As Outlook.Namespace  
      
    Set olNS = olApp.GetNamespace("MAPI")  
    olApp.ActiveExplorer.Display  
      
   Dim itm As Object  
   Const CtrlId As String = "MoveToOneNote"  
   For Each itm In olApp.ActiveExplorer.Selection  
     With itm.GetInspector  
       .Display  
       If .CommandBars.GetEnabledMso(CtrlId) Then .CommandBars.ExecuteMso CtrlId  
       .Close olDiscard  
     End With  
   Next  
 End Sub  

215008-screenshot-2022-06-09-205845-onenote-picker.jpg

215092-screenshot-2022-06-09-210430-onenote-file.jpg

Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,896 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Courtney 0 Reputation points
    2023-04-25T15:54:00.18+00:00

    Hi, I know this is an old thread but I found that if you check the box on the pop up window that says "Always send e-mail notes to the selected location" then it won't ask where to send the email, it'll just cycle through them. I'm sure there's a faster way, but that worked for me. You just have to remember to go into settings and un-check that box after you're done, unless you want to continue sending everything to the same place.


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.