Datei mit browser Auswaehlen uber VBA
01.09.2004 21:04:39
paralion
Ueber eine Inputbox den kompletten pfad einzugeben, ist nicht gerade benutzerfreundlich...
Ich hab da zwar ein script gefunden, funktioniert aber nicht...
zumindest nicht von word aus.
Ich bekomme die Fehlermeldung:
"Compile Error. Method or data Member not found"
-----------------
Sub OpenSingleFile()
Dim Filter As String, Title As String
Dim FilterIndex As Integer
Dim Filename As Variant
' File filters
Filter = "Excel Files (*.xls),*.xls," & _
"Text Files (*.txt),*.txt," & _
"All Files (*.*),*.*"
' Default Filter to *.*
FilterIndex = 3
' Set Dialog Caption
Title = "Select a File to Open"
' Select Start Drive & Path
ChDrive ("c")
ChDir ("C:\Documents and Settings\Admin\Desktop\test-db\")
With Application
' Set File Name to selected File
Filename = .GetOpenFilename(Filter, FilterIndex, Title)
' Reset Start Drive/Path
ChDrive (Left(.DefaultFilePath, 1))
ChDir (.DefaultFilePath)
End With
' Exit on Cancel
If Filename = False Then
MsgBox "No file was selected."
Exit Sub
End If
' Open File
Workbooks.Open Filename
MsgBox Filename, vbInformation, "File Opened" ' This can be removed
End Sub
-----------------------
Irgenwelche ideen?
Danke im Vorraus !