我尝试使用" docmd.openquery"运行现有查询并且成功。但是当我尝试使用" docmd.outputto"将查询结果输出到excel时方法,它给了我应用程序定义和对象定义的错误。有人可以帮忙解决这个问题吗?这是下面的代码。
Sub run_access_query()
Dim accessapp As Object
Set accessapp = CreateObject("Access.Application")
accessapp.Visible = False
accessapp.Opencurrentdatabase "U:\myAccess Databases\testdatabase.mdb"
With accessapp.DoCmd
.SetParameter "input_no", "20032967590"
.OpenQuery "test_query"
.OutputTo acOutputquery, "test_query"
End With
Set accessapp = Nothing
End Sub