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
0
votes
0 answers

User-defined type not defined for mscoree.CorRuntimeHost

I am trying to automate edge without installing selenium using VBA but I am getting error while using the selenium wrapper code, did I miss anything on this code or do I need to add any settings in my Excel addin? My code below: Function…
0
votes
1 answer

Implementing User-Defined Function (UDF) with IF equations

I'm working on a function that uses different formulas based on the DOH of a specific Person in different groups. Some groups may use different formulas depending on the status (if it's active or non-active). I need the results to be outputted in…
alxn
  • 1
  • 2
0
votes
2 answers

How to Construct a Key in VBA code Resulting in Run Time Error "Type Mis match"

basically the idea is I need to group the sum of figures based on the specific column in Sheet1 and update in Sheet 2... Right now the below code is throwing error on type mismatch on Key one. Columns ( 9, 10, 11, 18, 19, 20, 21) are the key columns…
Siva
  • 3,458
  • 8
  • 25
  • 26
0
votes
1 answer

Output formula results based on a word in a specific column and row

I'm building a function that uses different formulas based on the DOH of a specific Person in different groups. Some groups may use different formulas depending on the status (if it's active or non-active). I need the results to be outputted in the…
alxn
  • 1
  • 2
0
votes
0 answers

Saving file with VBA

I have an excel template stored at some specified location like my Desktop and I want to save that file through VBA as per list of names which are in column B (B2:B100) of another workbook. So, to shorten this I want my Workbook1 to be stored at…
0
votes
1 answer

Setting Array Formula doesn't SPILL to other cells (I'd like it to do so)

When I set an array formula, the formula doesn't Spill into the other cells the way I like it to. Usually, it goes to just one cell, hiding most of the presentation, but other times it seems to work. I can't understand what's happening. And…
Josh Marks
  • 79
  • 7
0
votes
1 answer

How do I Unzip a 7z zip file using VBA

I have a 7z .zip file I am trying to unzip with VBA. I have attempted several methods but to no avail. See below the zip file type just to be sure where the problem could be from: Image of 7z file I try the below code, it runs, downloads every…
bhukz
  • 3
  • 2
0
votes
2 answers

How can I provide Nothing (Null-Pointer) to a user defined type in VBA for using it as Windows API function argument?

In VBA, I declared a Windows API function that requires a pointer to a struct argument. For representing this struct I created a Public Type and declared the function parameter as ByRef. Now, this struct pointer may be null, so I tried to assign…
AxD
  • 2,714
  • 3
  • 31
  • 53
0
votes
1 answer

Lookup and see two different cell and then copy

My query is: I need a macro for IF A9 = "GBP" AND B9 = "GERMANY- ABS" AND NEW CELL = GERMANY The problem is B9 is not exact "GERMANY", it contains some other text so we should use LIKE function. Can you please help? i have macro or formula for…
Yaz Faaz
  • 11
  • 1
0
votes
1 answer

Doesn't show the value on the sheet

The code have to do this: Open the external file to push the information, if the id is the same at the other sheet they copy the value of the two columns and paste on the column on the sheet "Controle Geral", if he is not empty jump 2 columns and…
0
votes
1 answer

Word VBA delete every page except the front page

I have a Word template (1 page document) that merges several documents into the template. I need assistance with getting a code for deleting every page except the front page (first page). Every time the macro runs, it adds additional documents to…
zz5zz
  • 1
  • 1
0
votes
2 answers

Imports Word tables preserving format, but it splits the content of cells

I have a VBA macro that Imports Word tables preserving format, but it splits the content of cells. It seems that the break lines are causing the content to be split into several cells in excel. I am not very good at coding and could not find any…
Yahoo
  • 11
  • 3
0
votes
1 answer

The code is not extracting the complete specification part

I tried to extract the specification part for a few URLs, "Example Link - https://in.rsdelivers.com/product/3m/3400961/fall-arrest-fall-recovery-kit-3m-3400961/1965607", However, using the code below, I was only able to extract half of the specs;…
0
votes
0 answers

Word .dot file and writing VBA7 to connect sybase, got error run-time error '-2147467259(80004005)' method 'ActiveConnection' of object '_Recordset'

for office 365, we used word .dot file and writing VBA to connect sybase, but got error run-time error '-2147467259(80004005)' method 'ActiveConnection' of object '_Recordset' failed, our connection worked in office 2016 version. below is our…
Jason
  • 1
0
votes
0 answers

How to make a Ribbon Control read only in Excel either by CustomUI or VBA

I need to allow the user to navigate through the characters in the Ribbon input controls so they view them but editing. Currently I use 'onChange' method of the controls to set the value I want so the user can't provide their choice like below. Sub…
Dhay
  • 585
  • 7
  • 29