• Outlook User
  • New Outlook app
  • Outlook.com
  • Outlook Mac
  • Outlook & iCloud
  • Developer
  • Microsoft 365 Admin
    • Common Problems
    • Microsoft 365
    • Outlook BCM
    • Utilities & Addins

Copy Outlook Journal Entries to OneNote

Slipstick Systems

› Developer › Copy Outlook Journal Entries to OneNote

Last reviewed on December 4, 2018     9 Comments

Applies to: Outlook 2010

This macro still needs some work, specifically in testing for attachments and copying them to the page. It may also need more fields added and useless fields removed (which is no big deal). I am testing this only with Outlook 2010; it may work with Outlook 2007 versions if OneNote references are changed. It errors in Outlook 2013.

To use, you need to set a Reference to OneNote14 and XML in Tools, Reference.
Remember to set the references to OneNote and XML libraries

Select one or more Journal entries and run the macro. The selected journal items are added to OneNote, one journal entry per page.

By linking Contacts to OneNote (in the same OneNote section), you can make the journal entries subpages of the contacts.

Sample printout of journal entry in OneNote


Sub CopyJournalToOnenotePage()

Dim oJournal As Outlook.JournalItem
Dim oContact As Outlook.ContactItem
Dim spLinks As Outlook.Links
Dim spLink As Outlook.Link

Dim strJournal As String
Dim strContact As String

Set Selection = ActiveExplorer.Selection

For Each oJournal In Selection
Set spLinks = oJournal.Links

strContact = ""

For Each spLink In spLinks
    Set oContact = spLink.Item
    strContact = oContact.FullName & "; " & strContact
Next

Set spLink = Nothing

strJournal = "<b>Contact : </b>" & vbTab & strContact & vbCrLf & _
    "<b>Entry Type:</b>" & vbTab & oJournal.Type & vbCrLf & _
    "<b>Categories:</b>" & vbTab & oJournal.Categories & vbCrLf & _
    "<b>Company:</b>" & vbTab & oJournal.Companies & vbCrLf & _
    "<b>Start Time:</b>" & vbTab & oJournal.Start & vbCrLf & _
    "<b>End Time:</b>" & vbTab & oJournal.End & vbCrLf & _
    "<b>Duration:</b>" & vbTab & oJournal.Duration & " minutes" & vbCrLf & _
    "<b>Billing:</b>" & vbTab & oJournal.BillingInformation & vbCrLf & _
    "<b>Mileage:</b>" & vbTab & oJournal.Mileage & vbCrLf & _
    "<b>Last modified: </b>" & vbTab & oJournal.LastModificationTime & vbCrLf & _
    "<b>Notes: </b>" & vbTab & vbTab & oJournal.Body & vbCrLf & vbCrLf & "---- End Record ---"
 
    Dim oneNote As OneNote14.Application
    Set oneNote = New OneNote14.Application
    
    ' Get all of the Notebook nodes.
    Dim nodes As MSXML2.IXMLDOMNodeList
    Set nodes = GetFirstOneNoteNotebookNodes(oneNote)
    If Not nodes Is Nothing Then
        ' Get the first OneNote Notebook in the XML document.
        Dim node As MSXML2.IXMLDOMNode
        Set node = nodes(0)
        Dim noteBookName As String
        noteBookName = node.Attributes.getNamedItem("name").Text
        
        ' Get the ID for the Notebook so the code can retrieve
        ' the list of sections.
        Dim notebookID As String
        notebookID = node.Attributes.getNamedItem("ID").Text
        
        ' Load the XML for the Sections for the Notebook requested.
        Dim sectionsXml As String
        oneNote.GetHierarchy notebookID, hsSections, sectionsXml, xs2010
        
        Dim secDoc As MSXML2.DOMDocument
        Set secDoc = New MSXML2.DOMDocument
    
        If secDoc.LoadXML(sectionsXml) Then
            ' select the Section nodes
            Dim secNodes As MSXML2.IXMLDOMNodeList
            Set secNodes = secDoc.DocumentElement.SelectNodes("//one:Section")
            
            If Not secNodes Is Nothing Then
                ' Get the first section.
                Dim secNode As MSXML2.IXMLDOMNode
                Set secNode = secNodes(0)
                
                Dim sectionName As String
                sectionName = secNode.Attributes.getNamedItem("name").Text
                Dim sectionID As String
                sectionID = secNode.Attributes.getNamedItem("ID").Text
                
                ' Create a new blank Page in the first Section
                ' using the default format.
                Dim newPageID As String
                oneNote.CreateNewPage sectionID, newPageID, npsDefault
                
                ' Get the contents of the page.
                Dim outXML As String
                oneNote.GetPageContent newPageID, outXML, piAll, xs2010
                
                Dim doc As MSXML2.DOMDocument
                Set doc = New MSXML2.DOMDocument
                ' Load Page's XML into a MSXML2.DOMDocument object.
                If doc.LoadXML(outXML) Then
                    ' Get Page Node.
                    Dim pageNode As MSXML2.IXMLDOMNode
                    Set pageNode = doc.SelectSingleNode("//one:Page")

                    ' Find the Title element.
                    Dim titleNode As MSXML2.IXMLDOMNode
                    Set titleNode = doc.SelectSingleNode("//one:Page/one:Title/one:OE/one:T")
                    
                    ' Get the CDataSection where OneNote store's the Title's text.
                    Dim cdataChild As MSXML2.IXMLDOMNode
                    Set cdataChild = titleNode.SelectSingleNode("text()")
                    
                    ' Change the title in the local XML copy.
                    cdataChild.Text = oJournal.Subject
                    ' Write the update to OneNote.
                    oneNote.UpdatePageContent doc.XML
                    
                    Dim newElement As MSXML2.IXMLDOMElement
                    Dim newNode As MSXML2.IXMLDOMNode
                    
                    ' Create Outline node.
                    Set newElement = doc.createElement("one:Outline")
                    Set newNode = pageNode.appendChild(newElement)
                    ' Create OEChildren.
                    Set newElement = doc.createElement("one:OEChildren")
                    Set newNode = newNode.appendChild(newElement)
                    ' Create OE.
                    Set newElement = doc.createElement("one:OE")
                    Set newNode = newNode.appendChild(newElement)
                    ' Create TE.
                    Set newElement = doc.createElement("one:T")
                    Set newNode = newNode.appendChild(newElement)
                    
                    ' Add the text for the Page's content.
                    Dim cd As MSXML2.IXMLDOMCDATASection
                    Set cd = doc.createCDATASection(strJournal)

                    newNode.appendChild cd
                 
        
                    ' Update OneNote with the new content.
                    oneNote.UpdatePageContent doc.XML
                

                End If
            Else
                MsgBox "OneNote 2010 Section nodes not found."
            End If
        Else
            MsgBox "OneNote 2010 Section XML Data failed to load."
        End If
    Else
        MsgBox "OneNote 2010 XML Data failed to load."
    End If
    
    Next
    
Set oJournal = Nothing
Set oContact = Nothing

End Sub

Private Function GetAttributeValueFromNode(node As MSXML2.IXMLDOMNode, attributeName As String) As String
    If node.Attributes.getNamedItem(attributeName) Is Nothing Then
        GetAttributeValueFromNode = "Not found."
    Else
        GetAttributeValueFromNode = node.Attributes.getNamedItem(attributeName).Text
    End If
End Function

Private Function GetFirstOneNoteNotebookNodes(oneNote As OneNote14.Application) As MSXML2.IXMLDOMNodeList
    ' Get the XML that represents the OneNote notebooks available.
    Dim notebookXml As String
    ' OneNote fills notebookXml with an XML document providing information
    ' about what OneNote notebooks are available.
    ' You want all the data and thus are providing an empty string
    ' for the bstrStartNodeID parameter.
    oneNote.GetHierarchy "", hsNotebooks, notebookXml, xs2010
    
    ' Use the MSXML Library to parse the XML.
    Dim doc As MSXML2.DOMDocument
    Set doc = New MSXML2.DOMDocument
    
    If doc.LoadXML(notebookXml) Then
        Set GetFirstOneNoteNotebookNodes = doc.DocumentElement.SelectNodes("//one:Notebook")
    Else
        Set GetFirstOneNoteNotebookNodes = Nothing
    End If
End Function

More Information

The basic OneNote macro came from OneNote 2010: Create New Pages Programmatically Using OneNote.CreateOneNotePage
JournalItem Properties

Copy Outlook Journal Entries to OneNote was last modified: December 4th, 2018 by Diane Poremsky

Related Posts:

  • Transfer Outlook Notes to OneNote
  • Using Outlook’s Send to OneNote button
  • Create a List of Meeting Attendees and Responses
  • How to print a list of recurring dates using VBA

About Diane Poremsky

A Microsoft Outlook Most Valuable Professional (MVP) since 1999, Diane is the author of several books, including Outlook 2013 Absolute Beginners Book. She also created video training CDs and online training classes for Microsoft Outlook. You can find her helping people online in Outlook Forums as well as in the Microsoft Answers and TechNet forums.

Subscribe
Notify of
9 Comments
newest
oldest most voted
Inline Feedbacks
View all comments

Patrick
November 24, 2016 11:07 am

Hello
I use the Outlook 2016. Now I have the following problem: Dim spLinks As Outlook.Links "Links" is no longer there. What do I have to use?
Thanks Patrick

0
0
Reply
JBG
October 11, 2016 8:56 am

Diane,
I hope you can help me with this macro as I am a real Neophyte with VBA. I tried setting this up copying the instructions into VBA and have an error:
"Compile Error: User-Defined type not defined"
with the following section highlighted:
Dim secDoc As MSXML2.DOMDocument
Set secDoc = New MSXML2.DOMDocument
Can you help me fix this???
Thanks

0
0
Reply
Diane Poremsky
Author
Reply to  JBG
October 11, 2016 5:28 pm

You need to set a reference to xml and OneNote in tools, references.

0
0
Reply
Chris.
May 8, 2013 2:50 pm

Thanks very much for your reply Diane, you've given me a great starter. If I find myself with some time to look at this and come up with a solution I'll let you know

Regards,
Chris.

0
0
Reply
Chris.
May 7, 2013 3:34 pm

Hi Diane, this is great :)

did you ever update this to take attachments?

Also, is there a way to set the one-note date, time etc from the Journal note?

Regards,
Chris.

0
0
Reply
Diane Poremsky
Reply to  Chris.
May 7, 2013 5:23 pm

No, I haven't had time to figure out how to do attachments with it. I haven't done much (read: none) programming in OneNote so I'm not as familiar with the features. As for dates, I have no idea. We can get the date from outlook easily enough but i don't know if the date field is writable via vba in onenote.

0
0
Reply
Tim
January 15, 2013 11:07 am

Hi Diane, any chance you have a way to log a OneNote entry into the Journal in Outlook 2010? I'd like to see that when I look at my Journal, it shows that I took notes of a meeting in OneNote. Thanks, Tim

0
0
Reply
Diane Poremsky
Reply to  Tim
January 15, 2013 12:13 pm

I'll look into it... not sure it will be possible though.

0
0
Reply
Sumesh Krishnan
November 20, 2012 6:18 am

Thanks Diane! - This is a very good start for exporting Journals to OneNote.

0
0
Reply

Visit Slipstick Forums.
What's New at Slipstick.com

Latest EMO: Vol. 31 Issue 3

Subscribe to Exchange Messaging Outlook






Support Services

Do you need help setting up Outlook, moving your email to a new computer, migrating or configuring Office 365, or just need some one-on-one assistance?

Our Sponsors

CompanionLink
ReliefJet
  • Popular
  • Latest
  • Week Month All
  • Use Classic Outlook, not New Outlook
  • How to Remove the Primary Account from Outlook
  • Reset the New Outlook Profile
  • How to Hide or Delete Outlook's Default Folders
  • Disable "Always ask before opening" Dialog
  • This operation has been cancelled due to restrictions
  • Change Outlook's Programmatic Access Options
  • Removing Suggested Accounts in New Outlook
  • Adjusting Outlook's Zoom Setting in Email
  • Remove a password from an Outlook *.pst File
  • Opt out of Microsoft 365 Companion Apps
  • Mail Templates in Outlook for Windows (and Web)
  • Urban legend: Microsoft Deletes Old Outlook.com Messages
  • Buttons in the New Message Notifications
  • Move Deleted Items to Another Folder Automatically
  • Open Outlook Templates using PowerShell
  • Count and List Folders in Classic Outlook
  • Google Workspace and Outlook with POP Mail
  • Import EML Files into New Outlook
  • Opening PST files in New Outlook
Ajax spinner

Recent Bugs List

Microsoft keeps a running list of issues affecting recently released updates at Fixes or workarounds for recent issues in classic Outlook (Windows).

For new Outlook for Windows: Fixes or workarounds for recent issues in new Outlook for Windows .

Outlook for Mac Recent issues: Fixes or workarounds for recent issues in Outlook for Mac

Outlook.com Recent issues: Fixes or workarounds for recent issues on Outlook.com

Office Update History

Update history for supported Office versions is at Update history for Office

Outlook Suggestions and Feedback

Outlook Feedback covers Outlook as an email client, including Outlook Android, iOS, Mac, and Windows clients, as well as the browser extension (PWA) and Outlook on the web.

Outlook (new) Feedback. Use this for feedback and suggestions for Outlook (new).

Use Outlook.com Feedback for suggestions or feedback about Outlook.com accounts.

Other Microsoft 365 applications and services




New Outlook Articles

Opt out of Microsoft 365 Companion Apps

Mail Templates in Outlook for Windows (and Web)

Urban legend: Microsoft Deletes Old Outlook.com Messages

Buttons in the New Message Notifications

Move Deleted Items to Another Folder Automatically

Open Outlook Templates using PowerShell

Count and List Folders in Classic Outlook

Google Workspace and Outlook with POP Mail

Import EML Files into New Outlook

Opening PST files in New Outlook

Newest Code Samples

Open Outlook Templates using PowerShell

Count and List Folders in Classic Outlook

Insert Word Document into Email using VBA

Warn Before Deleting a Contact

Use PowerShell to Delete Attachments

Remove RE:, FWD:, and Other Prefixes from Subject Line

Change the Mailing Address Using PowerShell

Categorize @Mentioned Messages

Send an Email When You Open Outlook

Delete Old Calendar Events using VBA

VBA Basics

How to use the VBA Editor

Work with open item or selected item

Working with All Items in a Folder or Selected Items

VBA and non-default Outlook Folders

Backup and save your Outlook VBA macros

Get text using Left, Right, Mid, Len, InStr

Using Arrays in Outlook macros

Use RegEx to extract message text

Paste clipboard contents

Windows Folder Picker

Custom Forms

Designing Microsoft Outlook Forms

Set a custom form as default

Developer Resources

Developer Resources

Developer Tools

VBOffice.net samples

SlovakTech.com

Outlook MVP David Lee

Repair PST

Convert an OST to PST

Repair damaged PST file

Repair large PST File

Remove password from PST

Merge Two Data Files

Sync & Share Outlook Data

  • Share Calendar & Contacts
  • Synchronize two computers
  • Sync Calendar and Contacts Using Outlook.com
  • Sync Outlook & Android Devices
  • Sync Google Calendar with Outlook
  • Access Folders in Other Users Mailboxes

Diane Poremsky [Outlook MVP]

Make a donation

Mail Tools

Sending and Retrieval Tools

Mass Mail Tools

Compose Tools

Duplicate Remover Tools

Mail Tools for Outlook

Online Services

Calendar Tools

Schedule Management

Calendar Printing Tools

Calendar Reminder Tools

Calendar Dates & Data

Time and Billing Tools

Meeting Productivity Tools

Duplicate Remover Tools

Productivity

Productivity Tools

Automatic Message Processing Tools

Special Function Automatic Processing Tools

Housekeeping and Message Management

Task Tools

Project and Business Management Tools

Choosing the Folder to Save a Sent Message In

Run Rules on messages after reading

Help & Suggestions

Submit Outlook Feature Requests

Slipstick Support Services

Buy Microsoft 365 Office Software and Services

Visit Slipstick Forums.

What's New at Slipstick.com

Home | Outlook User | Exchange Administrator | Office 365 | Outlook.com | Outlook Developer
Outlook for Mac | Common Problems | Utilities & Addins | Tutorials
Outlook & iCloud Issues | Outlook Apps
EMO Archives | About Slipstick | Slipstick Forums
Submit New or Updated Outlook and Exchange Server Utilities

Send comments using our Feedback page
Copyright © 2026 Slipstick Systems. All rights reserved.
Slipstick Systems is not affiliated with Microsoft Corporation.

:wpds_smile::wpds_grin::wpds_wink::wpds_mrgreen::wpds_neutral::wpds_twisted::wpds_arrow::wpds_shock::wpds_unamused::wpds_cool::wpds_evil::wpds_oops::wpds_razz::wpds_roll::wpds_cry::wpds_eek::wpds_lol::wpds_mad::wpds_sad::wpds_exclamation::wpds_question::wpds_idea::wpds_hmm::wpds_beg::wpds_whew::wpds_chuckle::wpds_silly::wpds_envy::wpds_shutmouth:
wpDiscuz

Sign up for Exchange Messaging Outlook

Our weekly Outlook & Exchange newsletter (bi-weekly during the summer)






Please note: If you subscribed to Exchange Messaging Outlook before August 2019, please re-subscribe.

Never see this message again.

You are going to send email to

Move Comment