Access 2007/2010 VBA选择并上传Excel 2007格式文件
- 作者: 要上我随便
- 来源: 51数据库
- 2022-08-17
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
推荐阅读
