Hallo Zusammen,
ich habe folgendes Formular (Bildanhang) und den Code dazu. Ich möchte nun den ausgewählen Dateinamen in einer Tabelle speichern. Bekomme jeodch das Feld nicht gebunden??
Gruss
Option Compare Database
Option Explicit
Private Sub cmdFileDialog_Click()
' This requires a reference to the Microsoft Office 11.0 Object Library.
Dim fDialog As Office.FileDialog
Dim varFile As Variant
Dim SourceFile, DestinationFile, newFile As String
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
' Clear the list box contents.
' Me.FileList.RowSource = ""
' Set up the File dialog box.
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
With fDialog
' Allow the user to make multiple selections in the dialog box.
.AllowMultiSelect = False
' Set the title of the dialog box.
.Title = "Datei auswählen"
' Clear out the current filters, and then add your own.
.Filters.Clear
.Filters.Add "Access Databases", "*.MDB"
.Filters.Add "Access Projects", "*.ADP"
.Filters.Add "All Files", "*.*"
' Show the dialog box. If the .Show method returns True, the
' user picked at least one file. If the .Show method returns
' False, the user clicked Cancel.
If .Show = True Then
' Loop through each file that is selected and then add it to the list box.
For Each varFile In .SelectedItems
'Me.FileList.AddItem varFile
Me.File = varFile
SourceFile = varFile
' FileCopy(SourceFile, "c:\tmp\")
Next
Else
MsgBox "You clicked Cancel in the file dialog box."
End If
End With
End Sub
Hallo,
Wo ist denn das Textfeld "File" ?
Diesem wird doch schon der ausgewählte Dateiname zugewiesen ( Me.File = varFile) und kann auch an ein Tabellenfeld gebunden werden, d.h. im Steuerelementinhalt dieses Textfeldes steht der Tabellenfeldname.
Hast Recht! Die Tabelle wird nun gefüllt...
Kannst Du mir noch einen Tipp geben?
Ich möchte nun die Datei von varfile nach c:\tmp kopieren
varfile Wert ist:
c:\dokumente\test.doc
Ergebnis soll sein:
c:\tmp\test.doc
Hallo,
siehe VBA-Hilfe zu FileCopy.