Selasa, 30 Mei 2017

[MS_AccessPros] Problems with Access File Picker

 


Hope someone can help me here.

I am trying to use the built in file picker to obtain a selection of files.

I have followed the format as given in Access help but the issue arises when attempting to set the filters using .Filters.Add .

 

The first few (2 or 3) times it works fine, but from there on in I am being issued error 438: Object doesn't support this property or method

 

According to many posts I have found, this is a valid error when NOT using FileDialog(msoFileDialogFilePicker) but this IS what I am using.

 

The software used is: Access XP(2002) running on W10 Pro

 

The function is called from another Function running within the Class module of the Form I am using to test the function.

Both function are included within the class module.

 

Reproduced below is the code I'm using. Perhaps somebody can throw some light on the matter.

 

Input to function is shown here: ("Test - New File Picker", "D:\Users\David\Documents\Humour", "Word docs|*.doc;*.docx|Excel sheets|*.xls;*.xlsx|PDF fDocs|*.pdf", True)

 

Function PickSomeFiles(ByVal Title As String, _

ByVal InitialPath As String, _

ByVal Filters As String, _

ByVal AllowMultiSelect As Boolean)

      Dim fDialog As Office.FileDialog, splitFilters() As String, i As Long

20    On Error GoTo PickSomeFiles_Error

 

30        Set fDialog = Application.FileDialog(msoFileDialogFilePicker)

40        splitFilters = Split(Filters, "|")

50        With fDialog

60            .AllowMultiSelect = AllowMultiSelect

70            .Title = Title

80            .InitialFileName = InitialPath

90            .Filters.Clear

100           For i = 0 To UBound(splitFilters) Step 2

110               .Filters.Add splitFilters(i), splitFilters(i + 1) ' ERROR 483

120           Next i

130           If .Show = True Then

140               Set PickSomeFiles = .SelectedItems

150               Exit Function

160           End If

170       End With

180       Set PickSomeFiles = Nothing

 

PickSomeFiles_Exit:

190       On Error GoTo 0

200       Set fDialog = Nothing

210       Exit Function

 

PickSomeFiles_Error:

      '

      ' uncomment the next line if you want a msgbox

      '

      '   MsgBox "Error " & Err.Number & "(" & Err.Description & ")" & vbCrLf & _

      '          "on line #" & Erl & " of procedure PickSomeFiles " & vbCrLf & _

      '          "in Module Form_Test - New File Picker"

      '

      Dim params_report As String  ' load something in to the parameter list if you want

220       params_report = params_report

230       Call LogError( _

                 Err.Number, "#" & Erl & ": " & Err.Description, _

                 "Function" & ":" & _

                 "PickSomeFiles of " & _

                 "Form_Test - New File Picker", _

                 params_report)

240        GoTo PickSomeFiles_Exit

 

End Function


__._,_.___

Posted by: regularmail@disrees.com
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (1)

Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.


.

__,_._,___

Tidak ada komentar:

Posting Komentar