Use the keyboard to follow a hyperlink created by the HYPERLINK() function

sn0skier

New Member
Joined
Mar 29, 2017
Messages
9
Can someone tell me how I could follow a hyperlink that comes from the HYPERLINK() function without clicking on it using the mouse? No VBA solutions that I have found through google have worked for me.

Please note that this is different from following an inserted hyperlink. There is no context menu entry for "open hyperlink" for cells that contain hyperlinks based on the HYPERLINK() function; this only exists for inserted hyperlinks.

Honestly not sure it's possible, but it would be very useful for me.
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
So, I kind of figured it out. The best solution was to use the macro written in the second to last post here: http://www.vbaexpress.com/forum/sho...r-in-the-top-left-corner-of-the-selected-cell

That macro moves the mouse cursor to the active cell every time you change the active cell. That, in combination with AHK or some other hotkey program that allows you to assign mouse-click to a hotkey, will allow me to simulate a mouse-click on the link using the keyboard.

I have edited the script below to be compatible with x64 systems:

In a standard code module:

Code:
Public Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long

In the code module of the area you want to be able to use this function:

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'SetCursorPos _
    ActiveWindow.ActivePane.PointsToScreenPixelsX(Target.Left), _
    ActiveWindow.ActivePane.PointsToScreenPixelsY(Target.Top)
SetCursorPos _
    ActiveWindow.ActivePane.PointsToScreenPixelsX(Target.Left + (Target.Width / 2)), _
    ActiveWindow.ActivePane.PointsToScreenPixelsY(Target.Top + (Target.Height / 2))
End Sub
BTW, on the 3rd from last line you can change "(Target.Width / 2)" to what you need if your cells are left/right/center aligned and "(Target.Height / 2)" for top/bottom/middle aligned.
 
Upvote 0
Solution
Ugggh, I said I edited the script to work with x64 systems, and then I entered the old code that doesn't work

In a standard code module:


Code:
Public Declare PtrSafe Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long

Other code is correct.
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,187
Members
452,616
Latest member
intern444

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top