简体   繁体   English

将Excel数据传输到Access

[英]Transfer Excel data to Access

I'm following the instructions here http://software-solutions-online.com/excel-vba-export-worksheet-to-existing-access-table/ to transfer data from an Excel spreadsheet to an Access database. 我按照http://software-solutions-online.com/excel-vba-export-worksheet-to-existing-access-table/中的说明将数据从Excel电子表格传输到Access数据库。 The script I have adapted is: 我改编的剧本是:

Sub MailMerge2()
Dim strPath As String
Dim objAccess As Access.Application
Dim strExcelPath As String

strPath = "C:...Documents\MailMerge2"
strExcelPath = Application.ActiveWorkbook.FullName
Set objAccess = New Access.Application
Call objAccess.OpenCurrentDatabase(strPath)
objAccess.Visible = True
Call objAccess.DoCmd.TransferSpreadsheet(acImport, _
acSpreadsheetTypeExcel8, "MyTable1", strExcelPath, _
True, "A1:D11")
End Sub

However, running this gives me an error saying: 但是,运行这个给我一个错误说:

Run-time error: 7866, Microsoft Access can't open the database because it is missing, or opened exclusively by another user, or it is not an ADP file. 运行时错误:7866,Microsoft Access无法打开数据库,因为它丢失,或由其他用户独占打开,或者它不是ADP文件。

Any suggestions on which of these the problem is? 有关这些问题的哪些建议? I'm fairly new to Access, and haven't quite got the hang of the terminology yet. 我是Access的新手,还没有完全掌握术语。

Found the problem. 发现了问题。 I left out .accdb in my Access db file names. 我在我的Access db文件名中遗漏了.accdb

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM