Turn OneNote page into Reminder task


Does anybody know how to use KM to take a OneNote page and create a Reminder? I’m thinking the title on the OneNote page should be the title in the Reminder task and the body of the OneNote page is pasted as plain text as the Reminder notes?

I use OneNote as my go-to note taking app, and it would be very useful to change the title of the page to a task description and then quickly make the page into a task with the body providing the details.

Bonus points if the page is then moved to a different section for archiving :blush:

So this one was pretty fun … :slight_smile:

Sorry to post it this way rather than uploading the completed macro. I don’t have an easy way to share files publicly and the forum won’t let me attach anything other than images. Happy to upload the macro if there’s somewhere that’s easily accessible.

I wrote the macro in a few different parts, and I’ll try to explain each in turn. Note that I have pause for 0.5 seconds steps throughout to give the UI a chance to catch up to the processor. I don’t know if they are strictly necessary, but it makes me feel better to include them. :slight_smile:

1. Get OneNote title and body

I wrote this assuming that a) OneNote is the frontmost application, and b) the app is not in edit mode. To exit edit mode, click on the title of the note in the note list (middle rail). The name of the note will be highlighted in a slightly darker grey and the blinking cursor will disappear in the note editor.

The macro first activates OneNote (just to be safe) and selects Copy from the edit menu. If the app is out of edit mode, this step should copy the entire note as text, including the title.

Next the macro splits the title from the rest of the note using a RegEx search. Forgive me that the search is clunkily written, as I’m still learning RegEx. It is:


That second capture group should strip out the 3-ish blank lines OneNote seems to add between the title and the body. Those groups are captured into a few variables for later use.

2. Get link to note and make it desktop-openable

When Copy Link to Note is selected, OneNote will put two links onto the clipboard. the first is the web address, which when clicked will open the note in Office 365 online. The second is the OneNote: link, which if modified a bit will open the note in the desktop app. Since I prefer the desktop app, I used RegEx to find the OneNote: link (the Search System Clipboard step) and then adjust the formatting (the Set Variable step … notice I added :// after OneNote at the start). That RegEx is:


Next the link and the note body are combined into one variable for use later on.

3. Make the Reminder using AppleScript

Next the macro uses an AppleScript to write directly to the Reminders database. Reminders does not need to be active or in focus for this to work (I don’t _think).

The first part of the AppleScript pulls the KM variables into the AppleScript, while the second part writes to the Reminders database.

Note that I did not set a due date or time in this macro. If you want to do that, then that line can be changed to:

make new reminder at end with properties {name:reminderName, body:reminderBody, due date:date "9/24/2020 7:00 PM"}

The text of the AppleScript is:

tell application "Keyboard Maestro Engine"
	set reminderName to getvariable "onenoteTitle"
	set reminderLink to getvariable "onenoteLink"
	set reminderBody to getvariable "onenoteBody"
end tell

tell application "Reminders"
	set mylist to list "Reminders"
	tell mylist
		make new reminder at end with properties {name:reminderName, body:reminderBody}
	end tell
end tell

4. Switch back to OneNote, ask where to move page to

This is the only part I couldn’t completely figure out. Just to be safe, the macro first re-activates OneNote. Then it selects the Move Page To ... menu item. In Outlook the analogous Move To dialog has a search function, but the one in OneNote doesn’t appear to have it. So the macro ends and OneNote waits for you to select the target section. If there’s a way to pre-select the target section, I’d love some feedback on how to do that.

Wrapping up

I hope this helps. It was fun for me to figure out how to do this. Sorry the post is so long, but I wanted to post the screenshots as well as the description to help recreating the macro. Again, if there’s a way to upload the

1 Like

Wow, EXACTLY what I was looking for! :smile: Thanks a lot, and sorry I didn’t reply sooner, need to check my notification settings. This is perfect, I’ll try it out right away. The last step may not be necessary as I move the page as part of my workflow, but it could be a great enhancement.

EDIT: made some minor adjustments:

  1. Added a “simulate keystroke” action to the very beginning which brings focus to the page list to remove that manual step (if you already have focus on the page you want to make into a task this does nothing): ctrl+cmd+G

Screenshot 2020-10-07 at 16.43.55

  1. Adjusted the Apple script a little bit to provide feedback at the end of the task generation, plus provides the option to create an Outlook task instead of a reminder (last part is not strictly needed). My task list is named “Tasks” (this is the default task list in Micrsoft ToDo and is then replicated in Reminders) which you set on the seventh code line:
tell application "Keyboard Maestro Engine"
	set reminderName to getvariable "onenoteTitle"
	set reminderLink to getvariable "onenoteLink"
	set reminderBody to getvariable "onenoteBody"
end tell

set myReminderApp to "Apple" -- either Microsoft or Apple
set theList to "Tasks"

if myReminderApp is "Microsoft" then
	tell application "Microsoft Outlook"
		set myList to task folder theList
		tell myList
			make new task with properties {name:reminderName, content:reminderBody}
		end tell
	end tell
	tell application "Reminders"
		set myList to list theList
		tell myList
			make new reminder with properties {name:reminderName, body:reminderBody}
		end tell
	end tell
end if
display notification "Reminder added to " & theList

Now you can use your prefered hotkey (I use cmd+shift+1) to create a task from anywhere in the page.

I noticed the link breaks when you move the page, so I simply removed it, it’s not super important.

Thanks again!!

Excellent addition, thanks!