Function GetFilename(ByVal str As String) As String Dim i Let i = InStrRev(str, "\") If i > 0 Then Let GetFilename = Right(str, Len(str) - i) Else Let GetFilename = str End If End Function Function FileExists(ByVal path As String) As Boolean
FileExists = Dir(path) <> "" End Function Sub okno()
Dim fDialog Set fDialog = Application.FileDialog(msoFileDialogOpen)
If fDialog.Show Then Dim rst As Recordset Dim str Set rst = CurrentDb.OpenRecordset("Tabulka1") For Each str In fDialog.SelectedItems MsgBox str Dim target target = "c:\temp\" & GetFilename(str) If FileExists(target) Then MsgBox ("Soubor uz existuje") Else Call FileCopy(str, target) 'CurrentDb.Execute ("INSERT INTO [Tabulka1] ([Pole1]) VALUES ('" & str & "')") rst.AddNew rst!Pole1 = str rst.Update End If Next str rst.Close Else MsgBox "Nic" End If End Sub
|