ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,226
- Office Version
- 2007
- Platform
- Windows
Hi,
I am using the code below but one part doesnt work correctly & i am unable to see the reason why.
I run the code & i then see a Msgbox pop up saying "PDF DOES NOT EXIST"
I am not told which PDF its refering to,can you see an issue in the code which would cause this.
Obviously it should say something like PDF 123 DOES NOT EXIST
Thanks
I am using the code below but one part doesnt work correctly & i am unable to see the reason why.
I run the code & i then see a Msgbox pop up saying "PDF DOES NOT EXIST"
I am not told which PDF its refering to,can you see an issue in the code which would cause this.
Obviously it should say something like PDF 123 DOES NOT EXIST
Thanks
Rich (BB code):
Private Sub HyperlinkAllInvoiceNumbers_Click()
Dim lastRow As Long, myPath As String, fileName As String, fName As Variant
myPath = "C:\Users\Ian\Desktop\REMOTES ETC\DR\DR COPY INVOICES\" 'FOLDER LOCATION OF WHERE PDF ARE SAVED
lastRow = Range("P" & Rows.Count).End(xlUp).Row
For i = 6 To lastRow
If Range("P" & i) <> "N/A" Then
If Not Dir(myPath & Range("P" & i) & ".pdf", vbDirectory) = vbNullString Then
ActiveSheet.Hyperlinks.Add Range("P" & i), myPath & Range("P" & i) & ".pdf"
Else
MsgBox "PDF " & Range("P" & i) & " DOES NOT EXIST.", vbExclamation, "PDF IS MISSING IN THE FOLDER"
End If
End If
Next i
MsgBox "ALL HYPERLINKS ARE NOW COMPLETE.", vbInformation, "HYPERLINKING THE INVOICE NUMBER"
End Sub