Code mở chọn tập tin Excel từ Access 2007 trở lên

2020-10-26 13:06

Private Sub cmdTimTapTin_Click()
Dim fDialog As Object
Set fDialog = Application.FileDialog(3)
With fDialog
.Title = "Chon Tap Tin"
.Filters.Clear
.Filters.Add "File Excel", "*.xlsx"
.Filters.Add "All Files", "*.*"
If .Show = True Then
For Each varFile In .SelectedItems
txtTapTinExcel = varFile
Next
Else
MsgBox "You clicked Cancel in the file dialog box."
End If
End With
End Sub