Access 2007/2010 VBA选择并上传Excel 2007格式文件

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

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