'Attribute VB_Name = "OpenDialog"
'Dialog Öffnen Excel Dateiauswahl'
Option Explicit
' ---------------------------------------------------------
' Funktion: dlgFileSelection
' Eingestellt von: Andre Schau
' Datum: 5. Juno 2006
' Kommentar:
' Parameter: alle optional, sPath wechselt LW und Directory
' Rückgabe: Erfolg: FileName, ansonsten False
' Aufruf:
Sub dlgAuswahl()
' 'Stringvariablen
Dim sFilter$, sTitle$, sPath$
'Variantvariablen
Dim vFile As Variant 'Bei Abbruch Boolean, sonst String
'Variablen für Dialogsteuerung setzen
sTitle = "Excel-Datei auswählen:"
sFilter = "Excel-Datei (*.xls),*.xls"
vFile = dlgFileSelection(, sTitle, sFilter)
If vFile = False Then End
'weitere Aktionen ...
End Sub
' ---------------------------------------------------------
Private Function dlgFileSelection(Optional sPath As String = "", _
Optional ByVal sTitle As String = "", _
Optional ByVal sFilter As String = "", _
Optional ByVal iFilterIndex As Integer = 1, _
Optional ByVal bMultiselect As Boolean = False) _
As Variant
If sPath <> "" Then ChDir sPath
dlgFileSelection = Application.GetOpenFilename(filefilter:=sFilter, _
FilterIndex:=iFilterIndex, Title:=sTitle, MultiSelect:=bMultiselect)
End Function