Questions tagged [vba7]

Visual Basic for Applications (VBA) is an event-driven, object-oriented programming language for writing macros, used for the MS Office suite as well as other applications. VBA is not equivalent to VBA6, VBA7, VB.NET, or VBS. If your question is specifically about programming any MS Office application, also use the appropriate tag: [excel], [ms-access], [ms-word], [outlook], [powerpoint] or [ms-project].

Visual Basic for Applications (VBA) is an event-driven programming language which was first introduced by Microsoft in 1993 to give Excel 5.0 a more robust object-oriented language for writing macros and automating the use of Excel. The language and its runtime quickly matured and began being used in products beyond Microsoft Office applications.

Differences between VBA 6.0 and VBA 7.0?

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

Reference

Differences between VBA 6.0 and VBA 7.0

308 questions
5
votes
1 answer

Excel Hyperlink function to open a specific page

Could anyone from this group can offer some advice on the problem I'm trying to solve? I was attempting to open a PDF document to a specific page using the Excel Hyperlink function. I tried to solve this mystery but to no avail. Hope someone can…
Bert
  • 49
  • 1
4
votes
3 answers

Sum rows based on cell value and then delete all duplicates

I have an Excel Sheet where some rows may contain the same data as other rows. I need a macro to sum all the values in that column and delete all the duplicates rows, except for the first one, which contains the sum of the rest. I have tried…
4
votes
1 answer

Optimizing the VBA Code and improve the performance

I have developed a VBA macro which is used to refresh the 5 SAP AAO Queries and then copy those queries data into tables saperately by removing duplicates and then loaded into the power query. There i add some calculated columns and then load that…
user3186707
  • 101
  • 9
3
votes
2 answers

Why do I need a space before the '^' operator in VBA for Excel 2013 or it will produce a compile time error "Expected list or separator"

If I type for example Sqr(a ^ 2 + b ^ 2) there is no error. But when I type Sqr(a ^ 2 + b^ 2) it produces a compile error which I do not understand: What is the function of ^ in VBA7 as opposed to _^ (underscore to show space) which denotes…
John Alexiou
  • 28,472
  • 11
  • 77
  • 133
2
votes
1 answer

What is the alternative for CopyMemory API to recover Excel IRibbonUI

I use below code to retrieve the IRibbonUI that was set on ribbon callback in Template_Rib global variable that randomly losing its value. But the CopyMemory API makes the Excel crash randomly. Is there any alternative for this CopyMemory API? #If…
Dhay
  • 585
  • 7
  • 29
2
votes
1 answer

How do I trigger a Module sub in Excel VBA when a specific cell has a certain value?

I am having trouble running a macro that copies data range (source) from one worksheet to the main worksheet (destination) based on a value selected in a cell in the destination worksheet. The copy sub works fine when ran separately, but when I try…
jchrist
  • 23
  • 3
2
votes
1 answer

eBay Digital Signatures for APIs VBA okay but Python Signature validation failed to fulfill the request

I can successfully get a response from eBay's REST API with a digital signature using the following VBA code (I have not included all the code as it is quite a lot, but below is the important part): Set http = New MSXML2.XMLHTTP60 created_time =…
atl-it
  • 41
  • 6
2
votes
0 answers

VBA script that add slicers to another workbook with Chart

I created a VBA script that creates a chart and places it on a separate workbook. To create this chart I have data (pivot table) in different worksheets from another workbook. I used that data to create chart and placed into a different workbook.…
2
votes
4 answers

Remove special characters from range in VBA

I have created a VBA code to remove all special characters available in a column. As an example I have a Alphanumeric character with some special characters in every cells of a column: Suppose in a cell I have a value: abc@123!-245 After executing…
Shaon Paul
  • 153
  • 1
  • 2
  • 14
2
votes
1 answer

literate through each word in the document and replace it with first letter of the word

I am writing a macro which would keep only the initials of all the words in a document by keeping all the spaces between these words and keeping the special characters of the text. The code is as follows Sub rewrite_document_with_Initials() Set…
VBAbyMBA
  • 806
  • 2
  • 12
  • 30
2
votes
2 answers

Fix BOM issues when reading UTF-8 encoded CSVs with VBA ()

I'd like to get fresh advice on the infamous issue caused by the Byte Order Mark ( or EF BB BF in hex) when trying to read UTF-8 encoded CSVs with VBA (Excel). Note that I'd like to avoid opening the CSV with Workbooks.Open or FileSystemObject.…
Lo Bellin
  • 485
  • 4
  • 20
2
votes
2 answers

Match any character except '

I want to match any character (case insensitive) except when preceded by a single quote followed by the text On Error Goto: Match: on error goto err_handler if aap = 0 then on error goto Myerrorhandler on error goto errorhandler1 on error…
Guus
  • 53
  • 3
2
votes
0 answers

VBA Excel 365 64-bit Winsock implementation problem

I am struggling with an issues related to porting VBA code from 32-bit into 64-bit excel. I would like to assure that I am trying to resolve it by myself already for two weeks, trying to modify the code, reading tones of forums, documents, web…
1
vote
2 answers

I have 1000 excel rows of values, some are duplicates, and I want to find what column number those values exist in on another tab in VBA

I have a workbook with two tabs. My first tab has rows added to it by various people everyday, and one cell entered is a city name. Everybody enters this city name different, for example, New York could be entered as NYC, NY, NwYrk, New York,…
Geofex
  • 21
  • 3
1
vote
1 answer

copy file from a folder to another knowing the file name typed in a text box

I am trying to create a code to copy a pdf file from a folder to another folder keeping same name and everything. when I type the file name in a textbox and click on a button I want the code to copy this file from a folder to another. my code is…
1
2 3
20 21