ciao NebbiaDB!
ben ritrovato.
Se ho capito bene prova a seguire i seguenti passi :
questo in un modulo standard:
Option Compare Database
Option Explicit
Public Function cmdFileDialog() As String
Dim fDialog As Object
Dim varFile As String
Set fDialog = Application.FileDialog(3)
With fDialog
.Title = "Select One or More Files"
.AllowMultiSelect = False
.Filters.Clear
.Filters.Add "all files", "*.*"
.InitialFileName = CurrentProject.Path & ""
If .Show = True Then
varFile = .SelectedItems(1)
Else
cmdFileDialog = vbNullString
End If
End With
cmdFileDialog = varFile
End Function
Public Function justFileName(FullPathName As String) As String
Dim lngSlashPos As Long
Dim revPath As String
revPath = StrReverse(FullPathName)
lngSlashPos = InStr(1, revPath, "")
If lngSlashPos <> 0 Then
justFileName = Left(revPath, lngSlashPos - 1)
Else
justFileName = FullPathName
End If
justFileName = StrReverse(Mid$(justFileName, InStr(1, justFileName, ".") + 1, Len(justFileName)))
'justFileName = StrReverse(justFileName)
End Function
e questo nella form, dovresti intuire facilmente come adattare i nomi dei controlli :
Option Compare Database
Option Explicit
Private Sub cmdFile_Click()
Dim lngSlashPos As Long
Dim fullPath As String
fullPath = cmdFileDialog
lngSlashPos = InStrRev(fullPath, "")
Me.txtPath = Mid$(fullPath, 1, lngSlashPos)
Me.txtFile = justFileName(fullPath)
End Sub
ciao, Sandro.