VBA参考库 [英] VBA Reference Libraries

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

问题描述

我是VBA的新手,并且一直在为Office编写一个小型宏应用程序.在基本相同的PC设置上,我们大约有80位用户,除少数用户外,其他所有用户都可以访问它.

I'm new to VBA and have been throwing together a small macro application for the Office. We've got about 80 users on essentially identical PC setups, and it will be accessed by all but a few users.

我一直在尝试使用Web服务引用来自动化访问网页,并且还将Microsoft脚本运行时引用加载到了项目中.我试图在测试PC上运行它,但它抱怨缺少参考.

I've been playing around with some automation of accessing web pages using the Web Services references, and I've also loaded the Microsoft Scripting Runtime references into the project. I attempted to run it on a test PC and it complained that there were missing references.

我不是特别想在80台PC上手动加载参考.

I don't particularly want to go around 80 PCs and manually load the references.

基本上,我的问题是我应该如何管理此宏应用程序向80个奇数用户的分发,以确保每次为每个用户加载引用.

My question, basically, is how should I manage the distribution of this macro-app to 80 odd users so as to ensure that the references will load every time for every user.

谢谢!

推荐答案

在大多数情况下,除非您有一些不寻常的引用,否则后期绑定将解决VBA中引用的问题.大多数问题是由库版本中的差异引起的,可以通过后期绑定来克服.对于VBA,通常建议您以早期绑定进行开发,而以后期绑定进行释放.后期绑定的主要缺点是将内置常量更改为值(速度不再是以前的问题.)

For the most part, late binding will solve problems with references in VBA, unless you have some unusual references. Most problems are caused by differences in library versions that can be overcome with late binding. With VBA, it is often recommended that you develop with early binding but release with late binding. The main disadvantage of late binding is changing built-in constants to values (speed is no longer the issue it used to be.)

所以:

Dim fs As Object 'Instead of FileSystemObject '
Dim xl As Object 'Instead of Excel.Application '

Set fs=CreateObject("Scripting.FileSystemObject")
Set xl=CreateObject("Excel.Application")

'Value instead of built-in constant '
ForReading=2
Set f = fs.OpenTextFile("c:\testfile.txt", ForReading)

这篇关于VBA参考库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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