Solved

Change and Add Hyperlinks in Excel

Posted on 2016-10-02
6
40 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
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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 31

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now