ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   New Users to Excel (https://www.excelbanter.com/new-users-excel/)
-   -   Excel variable for path (https://www.excelbanter.com/new-users-excel/241156-excel-variable-path.html)

Esgrimidor

Excel variable for path
 
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.




Any similar solution is also possible for me .

Thankxxx

Sean Timmons

Excel variable for path
 
That requires coding. Not sure if you know how to do that in Excel or not...

the resulting open would be "Y:\document\"&Range("A2")&"\proof.doc"

"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


JLatham

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


Esgrimidor

Quote:

Originally Posted by JLatham (Post 874047)
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

Thank very much.

In my spanish version the funcion is HIPERENLACE , instead of hyperlink.

I think the variable comes in a cell and the function invokes in other.


All times are GMT +1. The time now is 01:00 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com