I have this code below that opens a file dialog box and lets me select files and then writes the filename and filedatetime among other things to table...Everything works great but i'm trying to figure out how to only show files in the dialog box and not folders....In other words it should open up to the default directory of c:\ and show only pdfs, which I have working but it also shows all the folders available in c:\. Thanks!
Code:
Sub Sample()
Dim f As Object
Dim db As Database
Dim sSQL As String
Dim File As String
Dim FileTime As String
Set f = Application.FileDialog(msoFileDialogFilePicker)
Set db = CurrentDb()
f.AllowMultiSelect = True
f.Filters.Clear
f.Filters.Add "PDFS", "*.pdf"
f.InitialFileName = "c:\"
If f.Show Then
For i = 1 To f.SelectedItems.Count
File = Filename(f.SelectedItems(i))
FileTime = FileDateTime(File)
sSQL = "INSERT INTO [FaxTest] ([Rep], [Datestamp], [Fax], [Faxdate], [Timestamp]) VALUES(""" & Text0 & """, """ & Text2 & """, """ & File & """, """ & FileTime & """, """ & Text3 & """)"
db.Execute sSQL, dbFailOnError
Next
End If
End Sub
Public Function Filename(ByVal strPath As String) As String
If Right$(strPath, 1) <> "\" And Len(strPath) > 0 Then
Filename = Filename(Left$(strPath, Len(strPath) - 1)) + Right$(strPath, 1)
End If
End Function