I'm having a hard time and needing some help. i have a filedialog picker that i'm using and trying to get it to filter down to just access files but this one line is giving me a hard time, sometimes it works and sometimes gives me a runtime error 438 object doesn't support this property or method. The line always highlighted is .Filters.Add "Access", "*.accdb", 1
Code:
Public Function GetFileFolder(strType As String, strTitle As String) As String
'Add "Microsoft Office 14.0 Object Library" in references
Dim fDialog As Office.FileDialog
Dim varFile As Variant
Dim typeOfPicker As Integer
Select Case strType
Case "folder"
typeOfPicker = msoFileDialogFolderPicker
Case "file"
typeOfPicker = msoFileDialogFilePicker
End Select
Set fDialog = Application.FileDialog(typeOfPicker)
With fDialog
.Title = strTitle
.Filters.Clear
.Filters.Add "Access", "*.accdb", 1 'Having a hard time with the filter add,
.FilterIndex = 1
.AllowMultiSelect = False
.InitialFileName = "time1_be.accdb" 'filestart
If .Show = True Then
If .SelectedItems.Count = 0 Then
GetFileFolder = ""
End If
For Each varFile In .SelectedItems
GetFileFolder = varFile
Next
Else
GetFileFolder = ""
End If
End With
End Function
is there a syntax error that i'm missing? i do have my library set to Microsoft office 16 object library. is there a better way to get my filter to only show accdb files?