MS访问使用外部VBA代码 [英] MS access use external VBA code

查看:93
本文介绍了MS访问使用外部VBA代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用MS Access应用程序。



我想编写一些代码并在几个VBA应用程序中使用它... Access& Excel



在.Net中你只需创建另一个程序集并引用它..你如何在Access / VBA中共享代码?

< br $>
谢谢



我的尝试:



注意到我真的不知道该找什么。在Google上花了很多时间,却没有发现任何相关内容。

Working on an MS Access app.

I want to write some code and use it across a couple VBA apps...Access & Excel

In .Net you would just create another assembly and reference it.. How do you share code in Access/VBA?

Thanks

What I have tried:

Noting really as I have no clue what to look for. Spent a bunch of time on Google but didn't find anything relevant.

推荐答案

我认为最接近应用程序之间共享代码的东西(Access - Excel - Word - Powerpoint)将从一个应用程序导出代码模块,并使用ide将其导入另一个应用程序。



在vba编辑器的Project视图窗格中,右键单击模块名称,从弹出菜单中选择导出文件。将它保存到易于到达的位置。它保存为.bas文件。在另一个应用程序中,使用导入选项。



当您重新导出并重新导入代码模块进行更改时,这很麻烦。
I believe that the closest thing to sharing code between applications (Access - Excel - Word - Powerpoint) would be to export the code module from one application and import it into the other application using the ide.

In the vba editor, in the Project view pane, right click the name of the module, select "Export File" from the pop up menu. Save it to a location easy to get to. It saves as a .bas file. In the other application, use the "Import" option.

This is awkward when you make changes as you have re-export and re-import the code module.


AFAIK,VBA中没有这样的机制。代码保存为文档的一部分,无论是数据库文件还是.xl **工作簿。



您可以将代码编写为基于COM的代码。 DLL在你想要的任何其他东西,如C / C ++,C#,VB.NET,VB6(yuk!),在机器上注册它并使用COM引用写它的VBA代码。
AFAIK, there is no such mechanism in VBA. The code is saved as part of the document, be it the database file or the .xl** workbook.

You can write your code as a COM-based .DLL in anything else you want, like C/C++, C#, VB.NET, VB6 (yuk!), register it on the machine and write VBA code against it using a COM reference.


不确定您是否必须使用VBA,但我已使用ADOX和.NET来操作Access数据库,如 adox c# - Google搜索 [ ^ ]。使用.NET和OleDB的Excel文件,如使用MS Excel(xls / xlsx)使用MDAC和Oledb [ ^ ]。
Not sure if you must use VBA, but I have used ADOX and .NET to manipulate Access database as described in some of the articles found at adox c# - Google Search[^]. And Excel files using .NET and OleDB as described in Working with MS Excel(xls / xlsx) Using MDAC and Oledb[^].


这篇关于MS访问使用外部VBA代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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