Hyperlink with VBA

Radio_123 1 Reputation point
2023-01-10T14:23:24.557+00:00

Hi everyone,

We have a large folder with a bunch of files/folders on a shared drive. Our excel sheet(in that same large folder) keeps track of all of these files/folders and there is also a hyperlink for each file/folder. For some odd reason, all the hyperlinks recently got corrupted and none of them work, however the text is still there. Instead of manually linking over 1000 hyperlinks, does anyone know or have a chunk of code that I can plug into VBA and get all the hyperlinks automatically set correctly. I should mentioned that all the file names, and hyper-link names are the exact same string of text. I just need the actual hyperlink to be linked, the text is already there. I did some research and I'm not sure if there is an automatic solution, considering this is a shared drive, and not a local computer folder.

Thanks,

0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Michael Taylor 56,346 Reputation points
    2023-01-10T16:15:56.403+00:00

    I don't think a shared drive vs local computer folder matters here. Can you provide us a sample of the data you're talking about? Based upon your description it sounds like you have something like this:

    '\server\share\file1.txt' '\server\share\file2.txt`

    Each of those values in your Excel spreadsheet is a link that when clicked goes to the actual UNC in File Explorer. Is that correct?

    Do you really need the programmatic link? By default when Excel sees a URL/UNC text value it automatically treats it as a link. You don't have to do anything. Of course it does this when you add the text so you couldn't just remove the hyperlink programmatically as that would break it.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.