On your form vba code (class) add the following (assuming cmdgetfil is the button and rfino is the name of the file on the combobox (see green notes about adding .pdf)
Code:
Option Explicit
Private Sub cmdgetfil_Click()
Dim colFiles As New Collection
Dim direc As String
Dim filetosearch As String
filetosearch = Me.RfiNo
'you may need to add & ".pdf" onto the filetosearch line if the combobox doesn't have .pdf in it
direc = "\\106.154.208.10\qaqc\011. RFI&RRI PDF FILES"
RecursiveDir colFiles, direc, filetosearch, False
Dim vFile As Variant
For Each vFile In colFiles
OpenAnyFile (vFile)
Next vFile
'keep as false for a few tests so it only looks in your current folder
End Sub
Function OpenAnyFile(strPath As String)
If FileThere(strPath) Then
FollowHyperlink strPath
Else
MsgBox ("File not found")
End If
End Function
Function FileThere(FileName As String) As Boolean
If (Dir(FileName) = "") Then
FileThere = False
Else:
FileThere = True
End If
End Function
In a module add the following
Code:
Public Function RecursiveDir(colFiles As Collection, strFolder As String, strFileSpec As String, bIncludeSubfolders As Boolean)
'Debug.Print strFolder
Dim strTemp As String
Dim colFolders As New Collection
Dim vFolderName As Variant
strFolder = TrailingSlash(strFolder)
'Debug.Print strFolder & strFileSpec
strTemp = Dir(strFolder & strFileSpec)
'Debug.Print strTemp
Do While strTemp <> vbNullString
colFiles.Add strFolder & strTemp
strTemp = Dir
Loop
If bIncludeSubfolders Then
'Fill colFolders with list of subdirectories of strFolder
strTemp = Dir(strFolder, vbDirectory)
Do While strTemp <> vbNullString
If (strTemp <> ".") And (strTemp <> "..") Then
If (GetAttr(strFolder & strTemp) And vbDirectory) <> 0 Then colFolders.Add strTemp
End If
strTemp = Dir
Loop
'Call RecursiveDir for each subfolder in colFolders
For Each vFolderName In colFolders
Call RecursiveDir(colFiles, strFolder & vFolderName, strFileSpec, True)
Next vFolderName
End If
End Function
Public Function TrailingSlash(strFolder As String) As String
If Len(strFolder) > 0 Then
If Right(strFolder, 1) = "\" Then
TrailingSlash = strFolder
Else
TrailingSlash = strFolder & "\"
End If
End If
End Function
It works on mine opening a PDF
Let me know if you have any questions.