How to create OneNote links in Trello that open up in the desktop app?
Asked by Christian_Stenner:

Hey there,

I've been trying to attach OneNote links to Trello cards. They are supposed to automatically open within the desktop app so that I can quickly see the referenced material of the card.

My problem is the way Trello handles URLs.

The way to open a OneNote file would be to create the link from the note, then paste the link (which has two parts: The first is an URL to the web app and the second one to the desktop app).

The link to the desktop app always looks like this:

```
onenote:https://XYZ
```

Unfortunately, Trello doesn't recognize this as an URL. It converts the link to something like this:

Added as an attachment, it looks like this:

```
https://onenote:https://XYZ
```

Added in the description of a card it looks like this:

```
https://XYZ
```

Any ideas on how to "convince" Trello to use the desired URL format?


Answers:
author: Devon Henderson
body: Hi Christian!

I could not test this with OneNote as I don't use it, but I tested it with Evernote and it worked! Have you tried using the Markdown link formatting in the note description? It would look like this:

```
[Note name here](evernote:///view/2125064/s19/blahblahblah/)
```

When I use this, it opens the note in the Evernote app, which I believe is the behavior you're looking for in OneNote.

Hope this helps!

comments: author: Christian_Stenner
body: Hi Devon,

thank you so much. I didn't think about the markdown option. Yes, it really worked. This is how I format the link for OneNote:

```
[note name](onenote:https://d.docs.live.net/XYZ)
```


author: Devon Henderson
body: I'm happy that worked, Christian!

I would still submit a feature request to feature-ideas@trello.com to build this into the attachments section of the card, if that's a feature you want. This email goes right to Trello devs, so your voice is guaranteed to be heard :)

Have fun!


author: Christian_Stenner
body: Hey there,

since I started the post, I have created a "javascript" with regular expressions that can auto-format the OneNote links you load into the clipboard into markdown links. I use it inside TextExpander. This way, I just need to copy the link from inside OneNote and then enter the shortcode into the card's description. Takes about 5 seconds.

Looks like this:

```
// Start with the clipboard content

var result = TextExpander.pasteboardText;

// Add Syntax and global description for start section

result = result.replace(/^https/, "[OneNote Web-Link](https");

// Add Syntax for mid section

result = result.replace(/\n/, "\)\n[OneNote Desktop-Link](");

// Add closing bracets

result = result.replace(/\&end/, "&end)");

// Return the result

TextExpander.appendOutput(result);
```

What works: Links to sections and pages.

What doesn't work: Links to passages.

I hope this helps you when creating your own solution.

comments: author: Anthony Guillen
body: I was struggling with the very issue the OP mentioned, but I didn't want to subscribe to something like TextExpander. Just wanted a simple .exe program I could run with a custom-mapped shortcut (I use quicktextpaste), so that after copying the link from my OneNote page, I would hit my shortcut key combo and the nifty program would run in the background and convert it to markdown. Finally did it in Visual Basic via Visual Studio, and compiled. Mapped my Alt-C key combo to run the .exe file. I am *not* a coder, so don't judge. The code probably needs an error handler in case it's run without the proper onenote link in the clipboard, but I've reached the end of my abilities on this.

```
Sub Main()
' Gets the onenote link from the clipboard, assuming the onenote string is the last thing copied to clipboard
Dim source As String = My.Computer.Clipboard.GetText()

' Defines the result variable which will hold the end product
Dim result As String

' Used a variant of Replace function that would replace only the first instance of https since we don't want this touching the second one
result = Replace(source, "https", "[OneNote Web-Link](https",, 1)

' This Replace looks for the carriage return which is the demarcation between the onenote weblink and onenote desktop link. It replaces that with close parenthesis and a carriage return which is the Chr(13)
result = result.Replace(Environment.NewLine, ")" & Chr(13))

' The next two Replace function finish things off for the desktop link
result = result.Replace("onenote:", "[OneNote Desktop-Link](onenote:///")
result = result.Replace("&end", "&end)")

' Writes the finished product back to the clipboard
My.Computer.Clipboard.SetText(result)

' Gives a little message box so user knows it's done, because despite this thing being less than dozen lines long, it takes a couple seconds to execute
Windows.Forms.MessageBox.Show("OneNote Link Converted!")


End Sub
```

The story: I first tried Fiverr, and of course nobody wanted to do anything for less than like $50. And I'm cheap. So instead I wasted much more than that with a day of my time.

I googled around about how to just compile Christian's javascript to an .exe, but it seemed complicated. I know C# is used for desktop apps and I had Visual Studio Code on my pc for some reason, but after hours and hours discovered that apparently you basically can't get windows clipboard data using Visual Studio Code because it's cross-platform,.. So after installing Visual Studio, still couldn't figure out how to get clipboard data because I couldn't figure out how to get the references imported. Then I thought, maybe Visual Basic can do that easier, and viola, VB can easily get clipboard data. That was terrible. I should have paid a Fiverr seller $100 to do it instead.


author: Shaun Sheehan
body: Hi - links work for me.

In OneNote app I go to the page, right click and select*Copy Link to Page.* Then in the Trello card comment, click on the *Attachment* icon, paste the link (Ctrl+V), and type in the text you want to display (if other than the link which can be quite long and painful to look at). It does take a second or two to render upon save, but then I can access the OneNote page from the Trello card.

That said, when I click on the link to open it, it does open in the web version of OneNote and not the desktop app, but that's fair since I'm using Trello online and it still gives me access what I need.

comments: author: Christian_Stenner
body: Hi Shaun,

thank you.

Yes, I can open links in OneNote / OneDrive web when I save them as you described. This will be useful on-the-go.

It's faster, though, to open up my local notebook through the markdown link option as Devon mentioned above.

I think, I'll look for a way to auto-format OneNote's double-link for markdown so that I can choose from the web and online version depending on the situation.

Something like this:

```
[web note](https://onedrive.live.com/XYZ)
```

```
[desktop note](onenote:https://d.docs.live.net/XYZ)
```


author: Anthony Guillen
body: I had posted a few months ago my solution, a variant of the solution the OP himself came up with. But while he used a 3rd party subscription app called "Text Expander" to run the script, I wanted a standalone executable. I posted the code as a reply to a comment, which doesn't make it the latest reply. I'm reposting with an update to the code.

**My Original Post:** I was struggling with the very issue the OP mentioned, but I didn't want to subscribe to something like TextExpander. Just wanted a simple .exe program I could run with a custom-mapped shortcut (I use quicktextpaste), so that after copying the link from my OneNote page, I would hit my shortcut key combo and the nifty program would run in the background and convert it to markdown. Finally did it in Visual Basic via Visual Studio, and compiled. Mapped my Alt-C key combo to run the .exe file. I am *not* a coder, so don't judge. The code probably needs an error handler in case it's run without the proper onenote link in the clipboard, but I've reached the end of my abilities on this.

**Update:** Like the OP's 5/18/2020 solution, mine only worked for sections and pages. I went back and looked at why it wasn't working for passages. Turns out it was because while section and page links end with "\&end", passages don't - they end with a variety of different characters. So instead of using a final Replace function to replace "\&end" with "\&end)" to finish off the markdown string, I just appended ")" to the string by concatenating. Here is the result

```
Sub Main()
' Gets the onenote link from the clipboard, assuming the onenote string is the last thing copied to clipboard
Dim source As String = My.Computer.Clipboard.GetText()

' Defines the result variable which will hold the end product
Dim result As String

' Used a variant of Replace function that would replace only the first instance of https since we don't want this touching the second one
result = Replace(source, "https", "[OneNote Web-Link](https",, 1)

' This Replace looks for the carriage return which is the demarcation between the onenote weblink and onenote desktop link. It replaces that with close parenthesis and a carriage return which is the Chr(13)
result = result.Replace(Environment.NewLine, ")" & Chr(13))

' Replace function edits the beginning portion of the desktop link
result = result.Replace("onenote:", "[OneNote Desktop-Link](onenote:///")

' Now add the final close parenthesis that Trello needs to recognize it as a hyperlink
result = result & ")"

' Writes the finished product back to the clipboard
My.Computer.Clipboard.SetText(result)

' Gives a little message box so user knows it's done, because despite this thing being less than dozen lines long, it takes a couple seconds to execute
Windows.Forms.MessageBox.Show("OneNote Link Converted!")


End Sub
```

The story: I first tried Fiverr, and of course nobody wanted to do anything for less than like $50. And I'm cheap. So instead I wasted much more than that with a day of my time.

I googled around about how to just compile Christian's javascript to an .exe, but it seemed complicated. I know C# is used for desktop apps and I had Visual Studio Code on my pc for some reason, but after hours and hours discovered that apparently you basically can't get windows clipboard data using Visual Studio Code because it's cross-platform,.. So after installing Visual Studio, still couldn't figure out how to get clipboard data because I couldn't figure out how to get the references imported. Then I thought, maybe Visual Basic can do that easier, and viola, VB can easily get clipboard data. That was terrible. I should have paid a Fiverr seller $100 to do it instead.

My latest edit, thankfully, only took a few minutes to figure out.


Tags: ms-onenote

url