Function BestandOpzoekenAnne(Optional Pad As String) As String
Dim sType() As String, sFile As String, tmp As String, sPad As String
Dim bCheck As Boolean
Dim vrtSelectedItem As Variant
Dim fd As Office.FileDialog
On Error GoTo Hell
If Pad = "" Then sPad = CurrentProject.Path Else: sPad = Pad
If Right(sPad, 1) <> "\" Then sPad = sPad & "\"
Set fd = Application.FileDialog(msoFileDialogFilePicker)
With fd
.Title = "Selecteer een bestand." 'De titel voor het venster
.InitialFileName = sPad 'Waar moet het venster beginnen?
With .Filters
.Clear
.Add "Microsoft Word", "*.doc; *.docx; *.docm", 1 'Beperk de bestandstypes tot Word
.Add "Microsoft Excel", "*.xls; *.xlsx; *.xlsm", 2 'Beperk de bestandstypes tot Excel
.Add "Adobe Reader", "*.pdf", 3 'Beperk de bestandstypes tot .pdf"
.Add "Afbeeldingen", "*.jpg; *.jpeg; *.png", 4 'Beperk de bestandstypes tot afbeeldingen
.Add "Alles", "*.*", 5 'Geen Beperkingen op bestandstype"
End With
.FilterIndex = 1
.AllowMultiSelect = False 'Slechts één bestand kiezen toegestaan
.InitialView = msoFileDialogViewList 'Bepaal weergave
If .Show = -1 Then 'Bepaal of gebruiker op OK-knop heeft geklikt.
sFile = .SelectedItems(1) 'String wordt gevuld met geselecteerde bestand
Else
MsgBox "Er is op <Annuleren> gedrukt..."
BestandOpzoekenAnne = "Annuleren"
GoTo Hell
End If
End With
BestandOpzoekenAnne = sFile
Hell:
Set fd = Nothing
End Function