VBA 6.0和VBA 7.0有什么区别? [英] What are the differences between VBA 6.0 and VBA 7.0?
问题描述
我注意到Office 2010附带了Visual Basic for Applications 7.0.但是,我似乎找不到太多有关所做更改的文档.是否有人对更改进行了总结,或者是否有描述这些差异的资源?
I noticed that Office 2010 comes with Visual Basic for Applications 7.0. However I can't seem to find much documentation on what changes were made. Does anyone have a summary of the changes, or any resources describing the differences?
推荐答案
在VBA6和VBA7之间没有发生很多变化.引入VBA7是为了支持Office和Windows的64位版本(有关这些区别的信息,请参见下文).以下是主要更改:
There's not a whole lot that has changed between VBA6 and VBA7. VBA7 was introduced to support 64-bit versions of both Office and Windows (see below on what those differences are). Here are the key changes:
-
64位支持,主要用于API 通话.这都用于使您的代码与OS/Office版本以及其他版本(例如,在Office 2003/WinXP上的某人)一起使用.
64-bit support, primarily for API calls. This is both used to make your code work with your OS/Office version as well as others' (i.e. someone on Office 2003/WinXP)
-
如果使用的是64位版本的 Windows,但在32位版本上 Office,您可以声明API调用 像下面一样.
If you are on a 64-bit version of Windows, but are on a 32-bit version of Office, you can declare API calls like below. .
#If Win64 Then
Declare PtrSafe Function GetTickCount64 Lib "kernel32"() As LongLong
#Else
Declare PtrSafe Function GetTickCount Lib "kernel32" () As Long
#End If
如果使用的是64位版本的 Windows,和是64位版本 Office,您可以声明API调用 喜欢:
If you are on a 64-bit version of Windows, and are on a 64-bit version of Office, you can declare API calls like: .
#If VBA7 Then
Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As LongPtr
#Else
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal _
lpClassName As String, ByVal lpWindowName As String) As Long
#End If
要支持此功能,有:
-
三个新关键字(2种数据类型和 1个修饰符):
LongPtr
,LongLong
和PtrSafe
Three new keywords (2 data types and 1 modifier):
LongPtr
,LongLong
andPtrSafe
一个新功能:CLngLng()
(即
Int64)
One new function: CLngLng()
(i.e.
Int64)
所使用的新编译常量
以上:VBA7
和Win64
The new compilation constants as used
above: VBA7
and Win64
这篇关于VBA 6.0和VBA 7.0有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!