从Excel VBA运行接入模块 [英] Run access module from Excel VBA

查看:248
本文介绍了从Excel VBA运行接入模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我tryng运行在访问这个模块:

I am tryng to run this module on Access:

Public Sub Retriever_P(path)

DoCmd.TransferSpreadsheet acImport, 10, "Product_Details", path, True, ""

End Sub

从这个VBA code在Excel

From this VBA code in Excel

 Private Sub CommandButton210_Click()

Dim appAccess As Access.Application
Set appAccess = New Access.Application
Dim Target As String: Target = ThisWorkbook.Sheets("CODE").Cells(8, 4).Value
Dim path As String: path = ThisWorkbook.Sheets("CODE").Cells(5, 13).Value
appAccess.OpenCurrentDatabase Target
appAccess.Visible = True
appAccess.DoCmd.SetWarnings False
appAccess.UserControl = True
appAccess.DoCmd.OpenQuery "Clean Product_Details"
appAccess.Run "Retriever_P", path
appAccess.CloseCurrentDatabase

End Sub

不过,我得到这个错误2517,微软Access无法找到程序Retriever_P

But I get this Error 2517, "Microsoft Access cannot find the procedure "Retriever_P"

Excel的code是一个更大的宏,创建了一个数据库的一部分,然后将其发送到接入。 任何想法?

The Excel code is part of a bigger macro that creates a DB and then sends it to access. Any Ideas?

感谢你在前进!

推荐答案

我已经找到了解决方案:问题在于子的名字是一样的模块名称。我不知道它必须是不同的,但我希望有人会发现这很有用! 感谢所有的答案家伙!

I have found the solution: the problem was that the sub name was the same as the module name. I didn't know it had to be different, but I hope someone will find this useful! Thanks for all the answers guys!

这篇关于从Excel VBA运行接入模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆