View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.newusers
JLatham JLatham is offline
external usenet poster
 
Posts: 2,203
Default Excel variable for path

As Sean said, this takes a little coding to do, but I'll provide the code an
all you have to do is copy it, put it in the proper place and edit it to
match your worksheet and path setup. The comments in the code tell where you
have to change things.

To put this code in the proper place, open your workbook and RIGHT-click on
the name tab for the sheet where this is to be used and choose [View Code]
from the list that appears. That will open the VB Editor and present an
empty code module to you. Copy the code below and paste it into the module,
make any changes to the code that you need to and then close the VB Editor.

After you've done that, when you change the entry in the variable cell, it
will automatically rebuild the hyperlink in the other cell to point to your
document.

Here's the code:

Private Sub Worksheet_Change(ByVal Target As Range)
'change this to the address of the
'cell with %variable% in it
'make sure you have the $ symbols as shown
Const variableCell = "$D$9"
'change this to the address of
'the cell with the hyperlink
'to open your document in it
Const linkCell = "$F$9"
If Target.Address < variableCell Then
Exit Sub
End If
'change the portions within " marks to
'form the left and right portions of the
'hyperlink when added to the entry in
'the variable cell
ActiveSheet.Hyperlinks.Add Anchor:=Range(linkCell), Address:= _
"C:\Users\" & Range(variableCell) & _
"\Documents\My Word Document.doc", TextToDisplay:= _
"Link to Word Document"
End Sub


"Esgrimidor" wrote:


Excel variable for path

I would like propose a variable in an excel cell and launch a word
document from other excel cell

Y:\document\%variable%\proof.doc ,

where %variable% can take several values.

The taken value is proposed in an excel cell and seen.

'[image:
http://img40.imageshack.us/img40/8749/screenshot1251661545.jpg]'
(http://img40.imageshack.us/i/screenshot1251661545.jpg/)


Any similar solution is also possible for me .

Thankxxx




--
Esgrimidor