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

Missing toolbars and project explorer is missing from Microsoft VBA

Screenshot of the VBA Window I have tried: Disable Tablet Mode - This is disabled initially, so not an option. Press ALT to try and activate the toolbars. Right click everywhere on the VBA screen to check for toolbar options, I got none, just…
-1
votes
1 answer

User defined filter not working as expected - "contains" interpreted as "ending with"

I stumbled over a strange problem today with the "contains" filter creteria used to filter a worksheet based on text input to a activeX text field in a worksheet. All is shown in the attached screenshot. The worksheet with the textbox…
Spreader
  • 11
  • 3
-1
votes
0 answers

Cascading Combo box issue with vbs

I have a SQL statement for a cascading combo box. I am getting a syntax error. Any clue on how I remedy this issue? Form_frmNewHRTPAction.cboSiteBureau.RowSource = "SELECT [AgencyOgranizationDiv-Bur].BurDesc, [AgencyOgranizationDiv-Bur].DivCode" &…
Tyrone
  • 47
  • 7
-1
votes
1 answer

Understanding And/Or logic VBA

I'm so confused about why the second If statement works but the first one does not. The actual result I want is if the user does not enter Peach or Banana or Mango then show the message. The Or's in the sentence above makes the most sense. However,…
-1
votes
2 answers

VBA Word find text with a special style in heading level/chapter

In the whole doc are data that I need to write in a predefined excel per chapter (headings level 1 - 4) there are findings (text with bulleted style) so if there is a finding in this chapter i have to look how many times so i can write it in excel…
-1
votes
2 answers

Write a dynamic sum formula vba that takes range from another sheet

screenshot of code I am trying to calculate sum in cell "I13" of sheet2 with inputs based on the dynamic range. Formula range("I13").formula= "=sum('sheet1'!A1:A3)" works but the range can be dynamic. For this I have used lr to identify the last…
AKK
  • 1
  • 1
-1
votes
1 answer

Looking for a Macro code to update corresponding columns

I have a column which has single and multiple languages such as "English", "French", "Russian", "English or Dutch", "French & English". My query is I would like to write macro code where if we have single language (English) then it should be updated…
Bash
  • 3
  • 2
-1
votes
1 answer

Sort the digits in the cell value using a VBA function

Can any one help me with VBA code. I want to sort the number in ascending and descending order in excel but a single cell value. For instance, if user entered 5634 in "A1" cell i want the result in "A2" as "3456" (i.e ascending) and in "A3" "6543"…
-1
votes
1 answer

What is the difference between InputBox () and Application.InputBox()?

When I write this sub: Sub IB() result = Application.InputBox("type a number", , , , , , , 1) End Sub The method InputBox has "type" as its last optional parameter, which allows you to restrict the datatype a user can insert. I set it to "1" in…
-1
votes
1 answer

How to format a number in Lakhs (indian format) when i copy an amount from excel to word using excel vba

I am trying create a tool to generate bulk salary revision files and facing an issue to get the correct number format in word file when it is copied from excel to msword (using bookmark). What is the best way to get the correct Indian number formats…
prasad
  • 1
  • 2
-1
votes
1 answer

Which function can i use in vba similar to the one i used in sql

i have tis code in sql and it works but which function can i use in vba to archive the same result. RIGHT('00' + MONTH(lt.LveFromDate),2) --2021-03 --2021-03 --YEAR(lt.LveFromDate)
james
  • 31
  • 6
-1
votes
1 answer

Getting the Cell Address of Checkbox when ticked

Hy, I am working on Excel VBA which will get me the Cell Address of the Checkbox I tick at the moment. I am able to get the cell address using following code. Sub test() Dim ws As Worksheet Set ws = Sheets("Sheet 1") Dim chk As…
abdulsamad
  • 158
  • 1
  • 10
-1
votes
1 answer

Execute .SQL file with VBA

I would like to know if there is any VBA code which allows me to execute .sql files by clicking a button in Excel? I've been surfing different webs, but all of them showed code which consists into write the SQL query in the macro, despite it isn't…
-1
votes
1 answer

Troubled with VBA version difference: version 6 and version 7

I'm new to VBA and use excel 2010 64bit VBA v6.0 compatible. I pasted the code, trying to download files through VBA. Option Explicit 'Tutorial link: https://youtu.be/H4-w6ULc_qs #If VBA7 Then Private Declare Function URLDownloadToFile Lib…
-2
votes
1 answer

Use Word VBA to find the Window ID of another open APP window

EDIT: "I realized after posting this question that the code does not actually switch to another window but it does get the Window ID Number. thus I modified the question to reflect what the Code actually does. I did get the code to work as 64 bit…
DryBSMT
  • 51
  • 2
  • 12
1 2 3
20
21