generating hyperlinks

  • Thread starter Thread starter swmasson
  • Start date Start date
S

swmasson

Hi there,

Does anyone know if it is possible to type "MA-00-25-987" in cell A
and let excel automaticall generate a hyperlink to "C:/m
documents/MA-00-25-987.pdf"

I thought it might be possible using a macro or something, but i'm no
really sure?

Thanks for your time.

Kind regards

swmasso
 
thanks, but i am using 50 columns and am trying to minimise the amoun
of them, do you know if there is a way of doing the same job withou
the extra column?

thanks again

swmasso
 
Using what Frank said,
right click sheet tab>view code>insert this>save

'Now when you put something in col B below row 2 the hyperlink should be
created.
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo fixit
If Target.Row > 2 And Target.Column = 2 _
And Len(Target) > 1 Then
Application.EnableEvents = False
Target.Formula = _
"=HYPERLINK(""C:/my documents/" & Target & ".pdf"")"
fixit:
Application.EnableEvents = True
End If
End Sub
 
Hi ...swmasson...,

You can shorten the HYPERLINK suggestion of Frank's to
=HYPERLINK("C:/my documents/" & A1 & ".pdf","[x]")
because there is NO need/reason to repeat the content of A2.

I think a DoubleClick Event procedure would work best for you,
as you do not make any change to the worksheet, and you can
edit the content in the "A" column without taking the link.
This is by far the easiest to maintain should you want to change
the location of a directory.

Untested by similiar to to example shown near (currently above)
http://www.mvps.org/dmcritchie/excel/event.htm#followhyperlink
To install RightClick on worksheet tab, view code, insert code.

Private Sub Worksheet_BeforeDoubleClick(ByVal _
Target As Range, Cancel As Boolean)
Dim hlink As String
Cancel = True 'Get out of edit mode
If target.row = 1 then exit sub '-- exit if row 1 descriptions
If Target.Column = 1 And trim(target.value)<>"" then
hlink = "c:/my documents/" & target.value & ".pdf"
ActiveWorkbook.FollowHyperlink Address:=hlink, NewWindow:=True
End If
End Sub

If the worksheet is for others you could format the column as
blue, underscored so they look like links, and then change the
A1 entry for your descriptions as non underscroed black.
Though it would be better to tell them to double click than to
make if look like something else in my opinion for the long term use.

Posted to the microsoft.public.excel newsgroup with no connection
to ExcelForum, one of several such entities whose presence makes
web searching difficult by duplicating newsgroup postings to webpages.
Google has a search for web pages, a search for (user) Groups, and
a search for images, etc.
 
Back
Top