跨 MS Office 应用程序共享 VBA 模块 [英] Sharing VBA modules across MS Office Applications

查看:33
本文介绍了跨 MS Office 应用程序共享 VBA 模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有大量用 Excel 2010 加载项编写的 VBA 模块.其中一些是特定于 Excel 的,但许多是更通用的.例如,获取零件编号并重新格式化它;另一个包含案例选择功能,用于在网络驱动器中查找文件.

I have a substantial bank of VBA modules written in an Excel 2010 add-in. Some of these are specific to Excel, but many are more general. For example one takes a part number and re-formats it; another contains a Case Select function to find a file in a network drive.

我想使用 Word 和 Outlook 中的常用功能.我可以从 Excel 复制并粘贴到 Word 加载项,但这使得我的代码难以保持最新 - 当我在一个应用程序中进行编辑时,我必须记住复制到所有其他应用程序.

I want to use the common functions in Word and Outlook. I could copy and paste from the Excel to Word add-ins, but this makes it difficult to keep my code up to date - when I make an edit in one application, I must remember to copy to all the others.

我的问题是,是否有任何方法可以在一个地方(例如在 Excel 加载项或其他一些常见位置)编写通用代码,以便所有 MS Office 应用程序都可以访问它,就像它只是另一个模块一样?

My question is, is there any means of writing common code in one place (e.g. in the Excel add-in, or some other common location) so that all MS Office applications can access it as it if it's just another module?

推荐答案

过去这样做的方法是使用 Visual Basic 6 将您的代码编译成 COM(或 ActiveX)DLL.然后您可以添加DLL,使用 VBA 编辑器的工具...参考"对话框,来自支持 VBA 的任何 Office(或其他)产品,与您可能使用的方式相同,例如,Microsoft 脚本运行时,它对于诸如 DictionaryFileSystemObjectTextStream.

The way this used to be done was to take your code and compile it into a COM (or ActiveX) DLL using Visual Basic 6. Then you could add that DLL, using the VBA editor's "Tools...References" dialog, from any Office (or other) product that supported VBA, the same way you might use, say, the Microsoft Scripting Runtime, which is super-handy for things like Dictionary, FileSystemObject and TextStream.

问题是,VB6 于 1998 年的某个时候发布,并且多年来一直没有从 Microsoft 获得或支持.似乎有很多下载站点都提供该软件包 - 我无法就使用它们可能遇到的合法性或安全问题提供任何建议...

Problem is, VB6 was released sometime in 1998 and has not been available from or supported by Microsoft for years now. There seem to be quite a few download sites offering the package - I can't offer any advice about the legality or security issues that might be experienced by using them...

可耻的是,微软几年前放弃了 VBA 球 - 似乎他们最希望它只是消失.

Shamefully, Microsoft dropped the VBA ball years ago - it seems they mostly wish it would just Go Away.

这篇关于跨 MS Office 应用程序共享 VBA 模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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