Hyperlink to single file in folder

bchacket

New Member
Joined
Jul 10, 2014
Messages
6
I have a database that stores folders for several different parts. What I am trying to do is have vba code that will find a folder within a part folder labeled "current drawing" and then hyperlink the only file in that folder. This file may change from time to time but there should only ever be one file in the folder. I all ready have a code that find the part folder and creates a hyperlink to that but the problem I have with hyperlinking to a drawing file is that the drawing file name could be anything.
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Please post your current code. You can use the Dir function to return the file name.

Code:
Dim Partnumber As Double
Dim CusName As String
Dim CusFirstLetter As String


Partnumber = PartnumberTextBox.Value
CusName = CusNameTextBox.Value
CusFirstLetter = Left(CusName, 1)

With Worksheets("Parts")
.Hyperlinks.Add Anchor:=.Range("E" & (ActiveCell.Row)), _
Address:="\\Engineering\Project\Customers\" & CusFirstLetter & "\" & CusName & "\" & Partnumber, _
ScreenTip:="Click to Open " & Partnumber & " Part Folder", _
TextToDisplay:="OPEN"
End With

This is what I use to hyperlink the part folder
 
Upvote 0
Untested, but try:

Rich (BB code):
Address:=Dir("\\Engineering\Project\Customers\" & CusFirstLetter & "\" & CusName & "\" & Partnumber) & "*.*", _
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top