Ms access FileDialog在Access 2016中不工作
我正在使用FileDialog代码将Excel表格导入Access 2013-32位,其工作方式与我所希望的完全相同。当我在Access 2016中使用代码时,代码中出现一个错误,上面写着“找不到库的项目”。我检查了我的参考资料,它们看起来是一样的 这是我的密码:Ms access FileDialog在Access 2016中不工作,ms-access,vba,Ms Access,Vba,我正在使用FileDialog代码将Excel表格导入Access 2013-32位,其工作方式与我所希望的完全相同。当我在Access 2016中使用代码时,代码中出现一个错误,上面写着“找不到库的项目”。我检查了我的参考资料,它们看起来是一样的 这是我的密码: Private Sub Command2_Click() Dim JobName As String Dim f As FileDialog Dim tblImport As String Dim varfile As Varian
Private Sub Command2_Click()
Dim JobName As String
Dim f As FileDialog
Dim tblImport As String
Dim varfile As Variant
Dim MyJobs As DAO.Recordset
JobName = lbl1.value
DoCmd.Close
Set f = Application.FileDialog(msoFileDialogFilePicker)
With f
.Title = "Choose Excel File(s) to Import"
.Filters.Clear
.Filters.Add "Excel Files", "*.xlsx"
.AllowMultiSelect = True
If f.Show = True Then
For Each varfile In .SelectedItems
Msgbox "IMPORTING: " & varfile
tblImport = varfile
DoCmd.TransferSpreadsheet acImport, 10, "Parts", tblImport, True
Next varfile
'Add Job Name to Parts Table
TempVars("jobName") = JobName
DoCmd.OpenQuery "Update Job Name"
'Add Job Name to Jobs Table
Set MyJobs = CurrentDb.OpenRecordset("Jobs")
MyJobs.AddNew
MyJobs![JobName] = JobName
MyJobs.Update
Set f = Nothing
Else
Msgbox "You Cancelled."
End If
End With
End Sub
如果取消选中对Microsoft Office库的引用并对代码进行以下两项更改,会发生什么情况
Dim f As Object
和Application.FileDialog(3)
@HansUp是谁做的!引用Microsoft Office库不会对其他应用程序或函数产生什么影响?我建议您确保所有代码模块的声明部分都包含Option Explicit
,然后从VB编辑器的主菜单运行Debug->Compile。如果删除对Microsoft Office库的引用在应用程序中产生了任何问题,Access会将这些问题显示为编译错误。如果取消选中对Microsoft Office库的引用并对代码进行这两项更改,会发生什么情况Dim f As Object
和Application.FileDialog(3)
@HansUp是谁做的!引用Microsoft Office库不会对其他应用程序或函数产生什么影响?我建议您确保所有代码模块的声明部分都包含Option Explicit
,然后从VB编辑器的主菜单运行Debug->Compile。如果删除对Microsoft Office库的引用在应用程序中产生了任何问题,Access将向您显示为编译错误。