Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import into evernote from excel spreadsheet
Option Explicit
Sub OutputNotesXML()
Dim iRow As Long
Close #1
With ActiveSheet
'For iRow = 2 To 2
Open "C:\Users\Robert\Downloads\Evernote\csv-export.enex" For Output As #1
Print #1, "<?xml version=" & Chr(34) & "1.0" & Chr(34) & " encoding=" & Chr(34) & "UTF-8" & Chr(34) & "?>"
Print #1, "<!DOCTYPE en-export SYSTEM " & Chr(34) & "http://xml.evernote.com/pub/evernote-export.dtd" & Chr(34) & ">"
Print #1, "<en-export export-date=" & Chr(34) & "20120202T073208Z" & Chr(34) & " application=" & Chr(34) & "Evernote/Windows" & Chr(34) & " version=" & Chr(34) & "4.x" & Chr(34) & ">"
For iRow = 2 To .Cells(.Rows.Count, "A").End(xlUp).Row
Print #1, "<note><title>"
Print #1, .Cells(iRow, "A").Value 'Title
Print #1, "</title><content><![CDATA[<?xml version=" & Chr(34) & "1.0" & Chr(34) & " encoding=" & Chr(34) & "UTF-8" & Chr(34) & "?>"
Print #1, "<!DOCTYPE en-note SYSTEM " & Chr(34) & "http://xml.evernote.com/pub/enml2.dtd" & Chr(34) & ">"
Print #1, "<en-note style=" & Chr(34) & "word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" & Chr(34) & ">"
Print #1, CBr(.Cells(iRow, "B").Value) 'Note
Print #1, "</en-note>]]></content><created>"
Print #1, .Cells(iRow, "D").Text 'Created Date in Evernote Time Format...
'To get the evernote time, first convert your time to Zulu/UTC time.
'Put this formula in Column D: =C2+TIME(6,0,0) where 6 is the hours UTC is ahead of you.
'Then right click on your date column, select format, then select custom. Use this custom code: yyyymmddThhmmssZ
Print #1, "</created><updated>201206025T000001Z</updated></note>"
Next iRow
Print #1, "</en-export>"
Close #1
End With
End Sub
Function CBr(val) As String
'parse hard breaks into to HTML breaks
CBr = Replace(val, Chr(13), "")
CBr = Replace(CBr, "&", "&amp;")
End Function
'I modified this code from Marty Zigman's post here: http://blog.prolecto.com/2012/01/31/importing-excel-data-into-evernote-without-a-premium-account/
@md2z34

This comment has been minimized.

Copy link

@md2z34 md2z34 commented Feb 10, 2013

Based on your work I've created another macro, which can read Evernote files into Excel worksheet. Here it is: https://gist.github.com/md2z34/4748871

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.