Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
686 views
in Technique[技术] by (71.8m points)

ms office - What are the differences between VBA 6.0 and VBA 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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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:

  1. 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)

    • 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
    • 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. To support this, there are:

    • Three new keywords (2 data types and 1 modifier): LongPtr, LongLong and PtrSafe

    • One new function: CLngLng() (i.e. Int64)

    • The new compilation constants as used above: VBA7 and Win64


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...