Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel VBA Multi-Hyperlinks in cell workaround

Status
Not open for further replies.

Dudder

Technical User
Jun 20, 2019
9
US
I'm trying to find all hyperlink strings surrounded by parentheses "(" & ")" in my active sheet and perform two functions.

Function 1 is to delete the parentheses when a hyperlink string is within them ( It must avoid parentheses that do not contain hyperlinks as they may contain necessary text notes.
Function 2 is to insert a PNG icon (Download link.png) to the left of the hyperlink string that is click-able and will open the relevant hyperlink.

Here is a thread where someone got a similar VBA script to work:

I'm having trouble modifying it to suit my needs. Could someone give this a shot and help me out?
Any help would be much appreciated.
 
Hi,

What code have you tried?

What error message or result did you get?

Can you post a representative sample of the data in your sheet, or upload?

BTW, you never responded to the cell merge issue that you posted earlier this month.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein
AD1D550E-FCB5-4AB6-A3C8-1F86CACE2554_ne1bcz.jpg
 
Hi Skip,

Thanks for chiming in.

For now I am using the function at this link exactly:
I don't know where to start modifying without breaking it.

For the line "ActiveSheet.Pictures.Insert(picpath).Select" I'm getting the error "Unable to get the Insert property of the Pictures class." I've attached a representative sheet to this post showing what I'm aiming to resolve.

Regarding the Cell Merge issue, thank you for the code you provided for that. Unfortunately after testing I saw what you meant, that Autofit will not work in merged cells. So I have put that issue on the backburner.

Any advice you have regarding this issue would be a huge help. Thx
 
Excel is not a word processor, so some functionalities are not available.
The simplest part: with I[tt]nStr[/tt] VBA function you can find required characters ("(" and ")") within the text, [tt]Mid[/tt] function will return required part of the string. You need an algorithm to verify, if the string found has proper address syntax.
The picture added is in the drawing layer, above the grid. If you remove the web address, you need to put some spaces to have room for image th the drawing layer.
You may have problem with locating address coordinates within the cell, there is no direct data for character - you plan to put image here.
To make the code from StackOverflow work you need macro enabled file saved and "link.png" file in the same directory. Note that the example code adds icons relatively to A1 (reference in calling [tt]PutLinksInACell()[/tt] procedure) and puts three icons ([tt]For i = 1 To 3[/tt] in [tt]insertPicture[/tt] procedure) regardless of the size of passed array.

To make things simple you could consider to have one link per cell, have text that is currently above hyperlink as text to display, format hyperling cell with standard colour and without underlining to hide hyperlink formatting.

combo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top