Insert Data from Excel into Access

前端 未结 5 1260
不思量自难忘°
不思量自难忘° 2020-12-18 11:04

I\'ve made some code to insert data from an excel table in to an access database - my code is as follow:

    Sub AddData()

Dim Cn As ADODB.Connection

Set C         


        
5条回答
  •  离开以前
    2020-12-18 12:03

    I think you cannot execute a query on just any open workbook. It MUST be run against a file, that means you have to provide a full path to you sheet, including the filename. If your workbook is "dirty", you need to save it first. I would rather

    • loop the worksheet lines and add the records one by one
    • or use the code you just wrote from Access (if it is suitable)

提交回复
热议问题