ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,832
- Office Version
- 2007
- Platform
- Windows
Morning,
I am using the code below but would like to check if file already exists.
Basically if file exists stop & show Msgbox advising user
If the file does not exist then continue
Currently nothing is in place & is just written over each time
I am using the code below but would like to check if file already exists.
Basically if file exists stop & show Msgbox advising user
If the file does not exist then continue
Currently nothing is in place & is just written over each time
VBA Code:
Private Sub HyperlinkDiscoII_Click()
Dim wb As Workbook
Const FILE_PATH As String = "C:\Users\Ian\Desktop\REMOTES ETC\DISCO II CODE\DISCO II PDF\"
If ActiveCell.Column = Columns("B").Column Then
If Len(Dir(FILE_PATH & ActiveCell.Value & ".pdf")) Then
ActiveCell.Hyperlinks.Add Anchor:=ActiveCell, Address:=FILE_PATH & ActiveCell.Value & ".pdf"
With ActiveCell
.Font.Size = 12
End With
MsgBox "HYPERLINK WAS SUCCESSFUL.", vbInformation, "POSTAGE SHEET HYPERLINK MESSAGE"
End If
Else
MsgBox "PLEASE SELECT A CUSTOMER FIRST TO HYPERLINK THE FILE.", vbCritical, "POSTAGE SHEET DISCO 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, "HYPERLINK CUSTOMER DISCO II MESSAGE.") = vbYes Then
CreateObject("Shell.Application").Open ("C:\Users\Ian\Desktop\REMOTES ETC\DISCO II CODE\DISCO II PDF\")
End If
End If
Unload DiscoIIHyperlink
Workbooks("DISCO CALC.xlsm").Close SaveChanges:=True
End Sub