Solved

Change and Add Hyperlinks in Excel

Posted on 2016-10-02
6
56 Views
Last Modified: 2016-10-04
I have an Excel worksheet with a column needs to hyperlinked with PDF files in the same folder, the column text has the same PDF file name.
1) Is it possible to Hyperlink all without going one by one ?
2) Also there are some text in the sheet already Hyperlinked and  needs to be changed ?
3) If the folder has been moved to other path is it going to work ?

Thanks
0
Comment
Question by:m_jundi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 9

Assisted Solution

by:Carlos Ijalba
Carlos Ijalba earned 50 total points
ID: 41825361
Hi m_jundi,

1)  you can writing a macro in vba that uses a table to update the addresses

2)  you cannot change that hyperlink with data>hyperlink>modify ?

3)  it is if you have used absolute paths, if you have used relative paths, you will have to change them and make them absolute, with this I mean:

Absolute: " \\SHARE\folder1\forlder2\document"
Relative: "..\..\document"

the absolute path will work on any PC with access to the share, the relative will only work when executed from the correct path.
0
 
LVL 8

Expert Comment

by:Koen
ID: 41825373
try following code:
Sub Macro3()
'
' Macro3 Macro
'

'
    Range("C2").Select
    Do While ActiveCell <> ""
    ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:= _
        ActiveCell.Value
    ActiveCell.Offset(1, 0).Select
    Loop
End Sub

Open in new window


Where your URL's are in column 3.
It will overwrite any existing url's
0
 

Author Comment

by:m_jundi
ID: 41825914
Koen,
1) as Carlos Ijalba advised do we need to change it to absolute paths ?
2) We need to add PDF extensions as the example shown below
3 ) Also advise if there are things need to be changed in the Macro except the the range

Example :
Column "F" DATA
A (Hyperlinked to A.PDF)
B (Hyperlinked to B.PDF)
C (Hyperlinked to C.PDF)

Thanks
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 33

Expert Comment

by:Rob Henson
ID: 41825957
If you use the HYPERLINK function you can create a hyperlink within the cell with variable inputs.

Syntax is:

=HYPERLINK(Link_Location, Friendly Name)

The Link Location can be put together as a string from various inputs using text functions. The Friendly Name is what appears in the cell and can be also be a cell reference.

Thanks
Rob H
0
 
LVL 8

Accepted Solution

by:
Koen earned 450 total points
ID: 41827115
I've adjusted the code... you now have 3 lines reading Mylink = ... you should only use one depending on the location of the files you are trying to link... (comment or delete the others)

and to answer your questions, yes absolute paths is always better; ".pdf" is added in the code below; I've changed the column to F per your data model...
should run fine...

Sub Macro3()
'
' Macro3 Macro
'

'
    Range("F2").Select
    Do While ActiveCell <> ""
    MyLink = "C:\directory\" & ActiveCell.Value & ".pdf" 'if the file is on the local machine
    MyLink = "\\Server\Directory\" & ActiveCell.Value & ".pdf" 'if the file is on a share
    MyLink = "https://yoursharepoint.com/site/library/" & ActiveCell.Value & ".pdf" 'if the file is on a sharepoint
    ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:=MyLink
    ActiveCell.Offset(1, 0).Select
    Loop
End Sub

Open in new window

1
 

Author Closing Comment

by:m_jundi
ID: 41827561
Thanks Koen, Perfect
0

Featured Post

Windows running painfully slow? Try these tips..

Stay away from Speed Up Computer Programs that do more harm than good.
Try these tips instead.
Step by step instructions in trouble shooting Windows Performance issues.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question