- Option Explicit
- Private Sub BrowseCmd_Click()
- With Application.FileDialog(msoFileDialogFilePicker)
- .AllowMultiSelect = False
- .Filters.Clear
- .Filters.Add "Excel 2007 Files", "*.xlsx"
- .Filters.Add "All Files", "*.*"
- If .Show = -1 Then
- FilePathTxt.SetFocus
- FilePathTxt.Locked = False
- FilePathTxt.Text = .SelectedItems(1)
- FilePathTxt.Locked = True
- End If
- End With
- End Sub
- Private Sub UploadCmd_Click()
- FilePathTxt.SetFocus
- If FilePathTxt.Text <> "" Then
- DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12Xml, "TableData", FilePathTxt.Text, True
- FilePathTxt.Locked = False
- FilePathTxt.Text = ""
- FilePathTxt.Locked = True
- End If
- End Sub
来源: http://www.phpxs.com/code/1008804/