运行vba脚本时出现错误Microsoft VBScript运行时错误:所需对象:'DoCmd' [英] While Running the vba script i am getting error Microsoft VBScript runtime error: object required : 'DoCmd'
本文介绍了运行vba脚本时出现错误Microsoft VBScript运行时错误:所需对象:'DoCmd'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
通过命令提示符运行vb脚本时,出现错误,指出Microsoft VBScript运行时错误:所需对象:'DoCmd'.
while running the vb script through command prompt i am getting the error stating that Microsoft VBScript runtime error: object required : 'DoCmd' .
请尽快帮助我.
ExecuteInsert
Sub ExecuteInsert()
Dim sheetPath
Dim dbs, DbFullName, acc
Set acc = createobject("Access.Application")
DbFullName = "D:\G\Diamond\FINAL MS-Access\Demo\MS-Access project.accdb"
Set dbs = acc.DBEngine.OpenDatabase(DbFullName, False, False)
dbs.Execute "Delete from TempRoadMap"
sheetPath = "C:\Users\270784\Desktop\CSPRV scheduled work - 2014 through 1-26-14.xlsx"
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel97, "TempRoadMap", _
sheetPath, True
MsgBox "Imported Sheet1 from " & sheetPath & " Successfully!"
dbs.Execute "Delete from RoadMap"
dbs.Execute "INSERT INTO [RoadMap] ( Release_Name,SPRF,SPRF_CC,Estimate_Type,PV_Work_ID,SPRF_Name,Estimate_Name,Project_Phase,CSPRV_Status,Scheduling_Status,Impact_Type,Onshore_Staffing_Restriction,Applications,Total_Appl_Estimate,Total_CQA_Estimate,Estimate_Total,Requested_Release,Item_Type,Path) SELECT [TempRoadMap.Release Name], [TempRoadMap.SPRF], [TempRoadMap.Estimate (SPRF-CC)],[TempRoadMap.Estimate Type],[TempRoadMap.PV Work ID],[TempRoadMap.SPRF Name],[TempRoadMap.Estimate Name],[TempRoadMap.Project Phase],[TempRoadMap.CSPRV Status],[TempRoadMap.Scheduling Status],[TempRoadMap.Impact Type],[TempRoadMap.Onshore Staffing Restriction],[TempRoadMap.Applications],[TempRoadMap.Total Appl Estimate],[TempRoadMap.Total CQA Estimate],[TempRoadMap.Estimate Total],[TempRoadMap.Requested Release],[TempRoadMap.Item Type],[TempRoadMap.Path] FROM [TempRoadMap] "
dbs.Close
MsgBox "Done"
End Sub
推荐答案
行
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel97, "TempRoadMap", _
sheetPath, True
除非您在其他位置定义了acSpreadsheetTypeExcel97
不存在,并且您应该使用acSpreadsheetTypeExcel8
,请参见
Unless you have defined elsewhere acSpreadsheetTypeExcel97
does not exist, and you should be using acSpreadsheetTypeExcel8
, see here for the different types
Not sure if this is correct but I have seen here that you should use object.docmd
so in your case would it be
acc.docmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel97, "TempRoadMap", _
sheetPath, True
这篇关于运行vba脚本时出现错误Microsoft VBScript运行时错误:所需对象:'DoCmd'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文