Creating a dynamic link in a workbook?

  • Thread starter Thread starter dziw
  • Start date Start date
D

dziw

Hey guys,

Quick question: I want to create a dynamic link to a file on the har
drive when I type the file name into a cell.

For example, if I put "aaaq4420" into a cell, I want it to link t
'c:\program\files\aaaq4420.dtf". I need this to happen automaticall
so it lauches the file by clicking on the cell (i.e. a hyperlink t
that file path).

Can anyone help me out??? I've looked at formulas, the autocorrec
function etc, and I keep hitting a wall.

Many thanks!
Mat
 
If you are entering the file name in the same cell each
time, and the path is always the same, you could do
something this.

'Assuming the cell is B2, put this in your Worksheet
Change event:

Private Sub Worksheet_Change(ByVal Target As Range)
'If you change cell B2
If Target.Address = ActiveSheet.Range("B2").Address Then
'Clear the cell
ActiveSheet.Range("B2").ClearContents
'Create hyperlink
ActiveSheet.Hyperlinks.Add
Anchor:=ActiveSheet.Range("B2"), Address:= _
"C:\PathName\" & ActiveSheet.Range("B2").Value,
TextToDisplay:=ActiveSheet.Range("B2").Value
End If
End Sub
 
*If you are entering the file name in the same cell each*

I'm actually hoping there was a way to format an entire column of cell
to be able to do this. Basically, I am tracking a large number of fil
names that I want to be able to link to instead of opening anothe
program, navigating to the file and opening it that way.
 
Back
Top