Hyperlinks in Text Boxes

bruntonomo

Board Regular
Joined
Jul 29, 2018
Messages
67
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Is there a way to place multiple hyperlinks in a single text box? Every time I select some text to make into a hyperlink, it makes the entire text box the link. I have a long Excel workbook comprised of long text boxes for ease of alignment purposes. I'm using Excel instead of Word because Word does not have a freeze frames function. I need the freeze frames for navigation of the document.

I know that I could make a million text boxes with hyperlink text to get around this, but that's seems super sloppy and majorly inconvenient. Any help would be greatly appreciated.
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
This is very close to what you want - click on textbox \ select a line number \ hyperlink is followed

To test

- insert NEW sheet with name "Links"
- in col A : friendly names prefixed by row number
- in col B: equivalent valid hyperlinks (see simple example below)
- do not use a header row (keeps things simple)

- on another sheet
- insert a simple textbox
- friendly names (as in col A above) are separate lines in textbox

The code
- assign macro to textbox
Code:
Sub TextBox1_Click()
    Dim shp As Shape, txt As String, LineNo As Long
    Set shp = ActiveSheet.Shapes(Application.Caller)
    txt = shp.TextFrame2.TextRange.Characters.Text
    LineNo = Application.InputBox("which line?", "Get text", 1, , , , , 1)
    Sheets("Links").Cells(LineNo, "B").Hyperlinks(1).Follow
End Sub

Notes
- this could be automated to make the list in the textbox autofill from values in column A etc

Excel 2016 (Windows) 32 bit
[Table="width:, class:head"][tr=bgcolor:#E0E0F0][th] [/th][th]
A
[/th][th]
B
[/th][/tr]
[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
1
[/td][td]1 Apple[/td][td]Sheet1!A1[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
2
[/td][td]2 Pear[/td][td]Sheet2!A1[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
3
[/td][td]3 Banana[/td][td]Sheet3!A1[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
4
[/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
5
[/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
6
[/td][td]Textbox
(on other sheet)
contains:[/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
7
[/td][td=bgcolor:#E2EFDA]1 Apple
2 Pear
3 Banana[/td][td][/td][/tr]
[/table]
[Table="width:, class:grid"][tr][td]Sheet: Links[/td][/tr][/table]
 
Upvote 0
Have you considered using a simple combobox (also known as DropDowns) ?
- select an item from the dropdown to follow the hyperlink

Add combobox like this
Developer tab \ Insert \ ComboBox from Form Controls (not active-x)

The code
- assumes the same layout in sheet Links as in previous example

the item number in the dropdown is the same as the row number in sheet Links
Code:
Sub DropDown1_Change()
    With ActiveSheet.Shapes("Drop Down 1").ControlFormat
        Sheets("Links").Cells(.Value, "B").Hyperlinks(1).Follow
    End With
End Sub

code to refresh the dropdown is simple too
Code:
Sub Refresh_DropDown()
    Dim Links As Worksheet, Cel As Range:    Set Links = Sheets("Links")
    With ActiveSheet.Shapes("Drop Down 1").ControlFormat
        .RemoveAllItems
        For Each Cel In Links.Range("A1", Links.Cells(Rows.Count, "A").End(xlUp))
            .AddItem Cel
        Next
    End With
End Sub

To test
- insert the combobox
- add the VBA
- place values in sheet Lists
- refresh dropdown
- select a value from dropdown
 
Last edited:
Upvote 0
Yongle, thank you so much for posting three responses. I really do appreciate your willingness to help. The drop down menus is actually already part of the plan on my project. They will be residing inside frozen panes at the top of the document for a fixed navigational header. However, these drop down menus will link to broader subject matters. Links in the main part of the document will link to more specific instances within those broader subjects. That's why I need both.

If I can hold off on a ton of programming, that would be fantastic. I guess I'm not sure why Excel cannot understand something as simple as hyperlinks in a text box. That seems to be a very serious oversight by Microsoft.
 
Upvote 0
The drop down menus is actually already part of the plan on my project. They will be residing inside frozen panes at the top of the document for a fixed navigational header. However, these drop down menus will link to broader subject matters. Links in the main part of the document will link to more specific instances within those broader subjects. That's why I need both.

I do not understand why you think this
- why can't you use dropdowns for both?

I presume that you understand that I am NOT referring to cell dropdowns
 
Last edited:
Upvote 0
A drop down menu in the body of the document won't work for what I'm trying to do. I apologize for not describing my project better in the original post. I have a ton of text because the project is an operating procedures manual. That's why I have text boxes. Simple links work best as the links are included within the context of what I'm writing. That's why a drop down menu won't really work. I would use Word, but they don't have frozen panes (fixed header). So I'm trying to make do with Excel.
 
Upvote 0
Does this describe what you want ?

A single textbox with multiple hyperlinks where any word or phrase contained in the textbox could be a hyperlink
 
Last edited:
Upvote 0
Below are screenshots of the layout I have created.

Section Menu
vaSTn5L


Body text

I used the text box tool to create the spaces where the text is.
Wa2QEQw
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,154
Members
453,021
Latest member
Justyna P

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