Creating a dynamic link in a workbook?

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
 
T

Tod

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
 
D

dziw

*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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top