ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,736
- Office Version
- 2007
- Platform
- Windows
Hi,
I have the code below.
Currently if i select the value in column D "example 123456" & run the code the hyperlink works fine providing the saved file is "example 123456.pdf"
This is where i need some help.
On my worksheet in column B will be the customers name.
Example
TOM JONES 001
STEVE SMITH 003
In column D will be a 6 digit value.
Example
1D3A21
2EE2D3
The Database folder will have pdf files saved like so.
TOM JONES 001 31D5F 31-08-2023.pdf
Customers name, 6 digit code then the day the file was saved then its extension.
How would i alter the code below so when i select a 6 digit code in column D the code would take in consideration the customers name in column B & the 6 digit code in column D & then look for it in the database folder.
Example BOB BROWN 35AC12 "when the saved file is BOB BROWN 35AC1A 31-07-2023.PDF" basically a partial look up of what its saved as
I have the code below.
Currently if i select the value in column D "example 123456" & run the code the hyperlink works fine providing the saved file is "example 123456.pdf"
This is where i need some help.
On my worksheet in column B will be the customers name.
Example
TOM JONES 001
STEVE SMITH 003
In column D will be a 6 digit value.
Example
1D3A21
2EE2D3
The Database folder will have pdf files saved like so.
TOM JONES 001 31D5F 31-08-2023.pdf
Customers name, 6 digit code then the day the file was saved then its extension.
How would i alter the code below so when i select a 6 digit code in column D the code would take in consideration the customers name in column B & the 6 digit code in column D & then look for it in the database folder.
Example BOB BROWN 35AC12 "when the saved file is BOB BROWN 35AC1A 31-07-2023.PDF" basically a partial look up of what its saved as
Rich (BB code):
Private Sub HyperlinkDiscoKey_Click()
Const FILE_PATH As String = "C:\Users\Ian\Desktop\REMOTES ETC\DISCO II CODE\DISCO II PDF\"
If ActiveCell.Column = Columns("D").Column Then
If Len(Dir(FILE_PATH & ActiveCell.Value & ".PDF")) Then
ActiveCell.Hyperlinks.Add Anchor:=ActiveCell, Address:=FILE_PATH & ActiveCell.Value & ".PDF"
MsgBox "DISCOVERY HYPERLINK SUCCESSFUL.", vbInformation, "DISCOVERY II HYPERLINK MESSAGE"
End If
Else
MsgBox "PLEASE SELECT A CUSTOMER FIRST.", vbCritical, "DISCOVERY II HYPERLINK MESSAGE"
Exit Sub
End If
If Dir(FILE_PATH & ActiveCell.Value & ".PDF") = "" Then
If MsgBox("THERE IS NO FILE FOR THIS CUSTOMER" & vbNewLine & "WOULD YOU LIKE TO OPEN THE DISCO II FOLDER ?", vbYesNo + vbCritical, "DISCOVERY II HYPERLINK CUSTOMER MESSAGE.") = vbYes Then
CreateObject("Shell.Application").Open ("C:\Users\Ian\Desktop\REMOTES ETC\DISCO II CODE\DISCO II PDF\")
End If
End If
End Sub