我想在 excel vba 中运行访问宏并复制访问查询。
当我运行下面的代码时,在 cn.DoCmd.RunMacro "runCopyqueryVragenlijsten" 行上出现运行时错误 3001
'~~> Select access file Database Questionmark.mdb
Set cn = CreateObject("adodb.connection")
Set rs = CreateObject("adodb.recordset")
cn.Open "provider=microsoft.jet.oledb.4.0;data source=D:\Data\Geschiktheidstesten en OPQ-rapport NMBS competenties\Analyse\Database Questionmark.mdb"
'~~> Run access macro
cn.DoCmd.RunMacro "runCopyqueryVragenlijsten"
'~~> Select access query to copy
rs.Open "select * from Copyquery_Vragenlijsten", cn
'~~> paste access query in sheet vragenlijst
Worksheets("vragenlijst").Range("a2").CopyFromRecordset rs
'~~> Close access file and put cursor on cell A1 of sheet evaluatierooster_NL
rs.Close
Set rs = Nothing
Set cn = Nothing