Sub doHyperLink()
Dim sPDFName As String
Dim sPDFPath As String
Dim XPath As String
Dim lastRowL As Integer
With Sheets("Ledger")
lastRowL = .Cells(.Rows.Count, "A").End(xlUp).Row
End With
sPDFName = Sheets("Invoice").Range("B18").Value & " " & Sheets("Invoice").Range("J2").Value & " " & Now & ".pdf"
sPDFPath = ActiveWorkbook.Path & Application.PathSeparator & "\" & "Invoice"
Sheets("Ledger").Range("L1").Value = sPDFName
Sheets("Ledger").Range("L1").Replace What:=":", Replacement:="_", lookat:=xlPart, SearchOrder:=xlByRows, MatchCase:=False
Sheets("Ledger").Range("L1").Replace What:="/", Replacement:="_", lookat:=xlPart, SearchOrder:=xlByRows, MatchCase:=False
XPath = sPDFPath & "\" & Sheets("Ledger").Range("L1")
Sheets("Ledger").Hyperlinks.Add Sheets("Ledger").Cells(lastRowL, 2), Address:=XPath
End Sub
|