Put text in Clipboard as Hyperlink to paste in Excel/Outlook

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
ukrsolid
Posts: 1
Joined: 24 May 2018, 11:59

Put text in Clipboard as Hyperlink to paste in Excel/Outlook

24 May 2018, 12:47

Hi,
I wonder if there is a way to put text in Clipboard as Hyperlink to paste in Excel/Outlook

So what I want is :
1. Select some report name (from text file etc)
2. Copy it to Clipboard via AHK (This step is implemented already)
3. Use AHK to create content in Clipboard
4. Go to Excel/Outlook and paste (Ctrl+V) it as a hyperlink


Here is C# version of what I want to do
https://stackoverflow.com/questions/459 ... th-c-sharp

Any thoughts on how we can implement it in AHK?

Thanks in advance.

Yarko
AHKStudent
Posts: 1472
Joined: 05 May 2018, 12:23

Re: Put text in Clipboard as Hyperlink to paste in Excel/Outlook

24 May 2018, 13:00

Hyperlink to what?

If you copied the words ABC and want to make it a hyperlink that is not a problem if you also provide where to link to

If you have a hyper link you copied and want to add a title that is not a problem too, if you have the title info
User avatar
FanaticGuru
Posts: 1907
Joined: 30 Sep 2013, 22:25

Re: Put text in Clipboard as Hyperlink to paste in Excel/Outlook

24 May 2018, 14:27

ukrsolid wrote:Hi,
I wonder if there is a way to put text in Clipboard as Hyperlink to paste in Excel/Outlook
You just need to put HTML code on clipboard and it will paste as a link in Excel.

Code: Select all

Title := "programmers"
Link := "http://programmers.stackexchange.com/"

Clipboard =
(
<html>
<a href="%Link%">%Title%</a>
</html>
)
Run that and the HTML code will be put on the clipboard as text where then you can paste it in Excel as you like.

This only works because Excel is smart and realizes the stuff on the clipboard looks like HTML and treats it as such.

This will not work on a lot of other software. For example, paste in Word and it shows the actual code and does not process as HTML. There is a way to put something on the clipboard as true HTML that any program that accepts HTML will use. It is considerably more complicated.

The clipboard is really a very amazing and complex piece of Windows coding. When you hit control-c, a ton of information is actually copied to the clipboard, containing all kinds of information about the source and what just got copied. Then when you hit control-v, depending on the destination, a ton of translating of all the stuff stored is worked out to paste what is assumed would be what the user wants. Whether it is text, pictures, HTML, files, tables, etc. For example, Coping 1 "character" from Word actually puts over 82,000 characters of information on the clipboard.

FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], Rohwedder, Scr1pter and 139 guests