使用VBA编辑器创建一个DLL [英] Create a DLL using VBA editor

查看:142
本文介绍了使用VBA编辑器创建一个DLL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个职位,我非常重视Visual Basic Macros全职,以支持公司的一些部门。我做得很好,学到了不少,并且很享受我的立场。



我们正在为未来制定计划,虽然我非常擅长搜索这些项目所需的信息(并且堆栈溢出已经是一个很好的资源在那里),我已经干了一些我一直在试图做的一些。



这是土地的铺路。我们通过公司所有人都可以访问的网络驱动器分发附加到各种其他程序的宏。这些宏还与我们公司使用的专有系统进行接口并自动化。因此,当对系统进行轻微的更改时,我们必须对大量的宏进行更改以便保持最新。



因此,什么我们想尝试的是制作一个与我们专有系统进行交互的方法DLL。我们想将该DLL放在网络驱动器上,并为其中的所有宏设置参考。不幸的是,我们至少暂时不能访问视觉工作室。所有我们在开发环境中都可以访问的是Visual Basic 6.5,因为它随Office一起打包。我们正在努力获得更多的收入,但是在大型公司工作的人都知道这一点。



所以,我想知道是否可能使用视觉基础编辑器创建一个DLL,如果我应该期望有几十个宏可能在同一时间访问它的任何问题。



提前感谢任何帮助或者您可以提供的建议。

解决方案

我假设您正在使用Office 2007产品。 VBA是一种脚本语言,用于构建您的宏。 DLL是编译程序集。 VBA编辑器将不允许您创建一个DLL。



您可以使用Visual Basic(而不是Visual Basic应用程序)创建一个DLL,然后在宏中引用它们。



您还可以使用.NET创建一个这个帖子中提到的非托管导出库,然后在宏中引用它。虽然没有必要,我建议使用Visual Studio构建一个DLL。



我会说明这一点 - 为什么不投资构建.NET应用程序(或Java或者更多的是企业内部的)比维护宏?您可能可以构建灵活的配置,以便在专有系统更改时,应用程序也会智能地更改其参数。这可能需要时间,但会减少通过宏的维护。



可能您没有选择。在这种情况下,我建议您拆分宏,只有一两个必须更改而不是许多。适当地减少依赖关系,并且所有易变化的宏都可以被带入单个位置。再次,这可能是不可行的。在这种情况下,请将所有宏并入其中,并将其组合到Web服务中(如果Visual Studio / .NET不可用,则可以使用开放源代码PHP / Python等),然后将办公产品更改为调用Web服务。有关在Excel中调用Web服务的信息,请点击此处


I have a position where I essentialy write Visual Basic Macros full time to support a number of divisions in the company. I've done quite well, learned quite a bit, and enjoy my position quite a bit.

We're laying out plans for the future, and while I'm quite good at searching for information I need for these projects (and stack overflow has been a great resource in that), I've come up dry on something I've been trying to do for a bit.

Here is the lay of the land. We distribute macros attached to various other programs via a network drive that everyone in the company has access to. These macros also interface with and automate a proprietary system our company uses. As such, when slight alterations to that system are made, we have to make alterations to a large number of macros in order to stay up to date.

As such, what we would like to try to do is to make a DLL of methods for interacting with our proprietary system. We would like to place that DLL on the network drive, and set the reference for all our macros there. Unfortunately, we do not, at least for the moment, have access to visual studio. All we have access to as far as development environments go is Visual Basic 6.5 as it comes packaged with office. We're working on getting more, but any of you that work at a large company know how that goes.

So, I'd like to know if it is possible to create a DLL using the visual basic editor, and if I should expect any issues having dozens of macros potentially accessing it around the same time.

Thanks in advance for any help or advice you may be able to offer.

解决方案

I assume you are using Office 2007 products. VBA is a scripting language, using which you build your macros. DLLs are compiled assemblies. VBA editor will not allow you to create a DLL.

You could use Visual Basic (not Visual Basic for Applications) to create a DLL and then reference them in your macros.

You can also use .NET to create an unmanaged export library as mentioned in this post and then reference it in your macros. Although not necessary, I'd recommend using Visual Studio to build a DLL.

I'll state the obvious - why not invest in building a .NET application (or Java or something more enterprisy) than maintaining macros? You may be able to build a flexible configuration so that when your proprietary system changes, the application intelligently changes its parameters also. This may take time but it will reduce maintenance through macros.

It is possible that you don't have a choice. In that case, I'd recommend splitting out your macros in a way that only one or two have to change instead of many. Reduce dependencies appropriately and all the change-prone macros could be brought into a single location. Again, that may not be feasible. In that case, take all the macros and combine them into web services (you could use open source PHP/Python etc. if Visual Studio/.NET isn't available) and then change your office products to call web services. A post about calling web services in excel is here.

这篇关于使用VBA编辑器创建一个DLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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