我正在尝试将Excel工作表数据传输到访问表。下面的代码会抛出错误变量而不是
Private Sub Cal_WEM_Click()
Dim appAccess As Object
Dim aPath, aDbase, aDSource, aTable, exePath As String
Dim fileParam As String
aPath = ActiveWorkbook.Path
aDbase = "Linear.accdb"
aDSource = aPath & "\" & aDbase
Set appAccess = CreateObject("Access.Application")
appAccess.Visible = True
appAccess.OpenCurrentDatabase aDSource
appAccess.DoCmd.TransferSpreadsheet transfertype:=acImport, _
tablename:="yorno", _
FileName:=aPath, Hasfieldnames:=True, _
Range:="WEM!D:E", SpreadsheetType:=5
appAccess.DoCmd.OpenForm "Input_Form_WEM"
Application.DisplayAlerts = False
ThisWorkbook.Saved = True
Application.Quit
Exit Sub
End Sub
答案 0 :(得分:0)
通过声明像这样的变量
来解决问题 Const acImport = 0
Const acSpreadsheetTypeExcel9 = 8
appAccess.DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, _
"wemonoff1", ename, True, "WEM-ONOFF!D:E"