Hi All
I work in an accounts team, where we store scanned PDF batches of financial transactions ( in this case scanned Accounts Payable invoices).
They are stored in directories on a network drive. e.g.:
//Network Name/Accounts Payable/Scanning/2012/01JAN etc
The files look like this "798653.pdf"
I have a macro below working that searches a specific directory (in this case I am telling it to look in 3 different spots, based on a populated URL/hyperlink in the spreadsheet, it then opens the PDF.
The user knows the "date" of the batch they are searching for, so the spreadsheet will generate a file path from the 2 inputs "798653" & "1/1/2012". It will create 2 alternate paths also, 1 month prior and after.
I'd like to eliminate the date, and have it search all directories within //Network Name/Accounts Payable/Scanning/ for any file name containing "798653"
Thanks Guys
<code>
</code>
I work in an accounts team, where we store scanned PDF batches of financial transactions ( in this case scanned Accounts Payable invoices).
They are stored in directories on a network drive. e.g.:
//Network Name/Accounts Payable/Scanning/2012/01JAN etc
The files look like this "798653.pdf"
I have a macro below working that searches a specific directory (in this case I am telling it to look in 3 different spots, based on a populated URL/hyperlink in the spreadsheet, it then opens the PDF.
The user knows the "date" of the batch they are searching for, so the spreadsheet will generate a file path from the 2 inputs "798653" & "1/1/2012". It will create 2 alternate paths also, 1 month prior and after.
I'd like to eliminate the date, and have it search all directories within //Network Name/Accounts Payable/Scanning/ for any file name containing "798653"
Thanks Guys
<code>
Code:
Sub APBatchSearch()
Dim BatchNumber As String
Dim BatchURL As String
Dim BatchURL2 As String
Dim BatchURL3 As String
Dim eScriptObject As Object
ActiveSheet.Calculate
BatchNumber = Range("APSscanBatchNumber")
BatchURL = Range("BatchURL")
BatchURL2 = Range("BatchURL2")
BatchURL3 = Range("BatchURL3")
Set eScriptObject = CreateObject("Scripting.FileSystemObject")
If eScriptObject.FileExists(BatchURL & BatchNumber & ".pdf") Then
ThisWorkbook.FollowHyperlink Address:=BatchURL & BatchNumber & ".pdf", NewWindow:=True
Else
If eScriptObject.FileExists(BatchURL2 & BatchNumber & ".pdf") Then
ThisWorkbook.FollowHyperlink Address:=BatchURL2 & BatchNumber & ".pdf", NewWindow:=True
Else
If eScriptObject.FileExists(BatchURL3 & BatchNumber & ".pdf") Then
ThisWorkbook.FollowHyperlink Address:=BatchURL3 & BatchNumber & ".pdf", NewWindow:=True
Else: MsgBox ("File Not Found")
End If
End If
End If
End Sub
</code>