C'è un modo per aprire una finestra di Windows Explorer da un modulo vba, navigare in un file specifico e selezionarlo in modo che il nome del file sia inserito in una casella di testo?Aprire Windows Explorer e selezionare un file
15
A
risposta
46
Partenza questo frammento:
Private Sub openDialog()
Dim fd As Office.FileDialog
Set fd = Application.FileDialog(msoFileDialogFilePicker)
With fd
.AllowMultiSelect = False
' Set the title of the dialog box.
.Title = "Please select the file."
' Clear out the current filters, and add our own.
.Filters.Clear
.Filters.Add "Excel 2003", "*.xls"
.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
txtFileName = .SelectedItems(1) 'replace txtFileName with your textbox
End If
End With
End Sub
Penso che questo è ciò che si sta chiedendo.
+13
Sei un bellissimo essere umano. – Quintis555
Premere il tasto magico 'F1' in VBA Excel e cercare' Application.GetOpenFilename';) –