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
vote
1 answer

Looping through files in folder successfully but all files print corrupted error

This code is supposed to open all files in the subfolders of my target folder and search them for specific terms, print those terms and where they were found in a text file. If it encounters an error, print that error so we know which documents to…
Jerwa
  • 23
  • 4
1
vote
1 answer

VBA Merge of Dynamic Named Ranges results into a static range i/o keeping dynamic

Context (VBA7.1 , Excel 2013 Pro): all sheets and dynamic named ranges (DNR) are created programmatically. I want to merge some of the DNR units (case of same data over several columns) into a single DNR for grouping them all. At this stage, the…
hornetbzz
  • 9,188
  • 5
  • 36
  • 53
1
vote
1 answer

Oracle 11g connectivity issue with VBA

I am trying to connect Oracle with VBA using connection string OraOLEDB.Oracle and it is throwing an error Provider not found MS Office 365 - 64 bit Oracle 11g - 64 bit Windows7 - 64 bit It is not possible for me to switch to 32 bit. It will be a…
Ishu
  • 11
  • 2
0
votes
1 answer

SendKeysToWindow Works One Time But Won't Repeat

I have an Excel workbook with a lot of business contacts. I need to send emails to some, but not all of them. Outlook is in an Enterprise environment and with only User permissions, I cannot make changes to the Macro or Object Model options in…
Bilbo
  • 3
  • 4
0
votes
1 answer

Passing Power Query M through VBA

I need to pass the following Power Query M through my VBA Script: let Source = Excel.CurrentWorkbook(){[Name="C192767TO15_D3"]}[Content], #"Changed Type" = Table.TransformColumnTypes(Source,{{"Item", type any}, {"Process Date", type datetime},…
0
votes
0 answers

Case and IF statement errors

I have been working on a piece of code and have ran into some errors with some if statements. I keep getting the error "block if without end if" I have changed my code around and done some research but have not been able to figure it out, me moving…
hakai
  • 1
0
votes
1 answer

Duplicate a button to have the same functionality in a different excel sheet

The code essentially duplicates data, creates a button, and transfers associated VBA code to a new workbook, allowing you to save the new workbook with the same functionality as the original workbook. Copies data from columns A to AK in the "Hub"…
loloel
  • 1
0
votes
1 answer

Problem with function to generate a DXF with a MTEXT

I'm working on an Excel spreadsheet to generate a DXF. So far I've been able to generate a function for lines, polylines, polygones, circles and simple text but I'm struggling to code a MTEXT function. This is what I have at this point: Function…
0
votes
1 answer

Have a newly created template sheet with table automatically append mater table. Building a fully automated template, hung up on the PowerQuery

The Project Premise: Creating a invoice tracking template that automatically appends a table on the newly created invoice worksheet to an existing table on the Master Worksheet. The process will work as follows: Existing: Invoice Template, Master…
0
votes
0 answers

How to make UserForm invoked from its parent file visible in all opened workbooks and enable selecting cells by InputBox?

I am working in Excel 365. I have a UserForm which lists all sheet names in target workbook (Name from a textbox). But the UserForm should be able to invoke from its parent file too (the file that contains the UserForm). The problem is if I invoke…
Dhay
  • 585
  • 7
  • 29
0
votes
1 answer

Locking the Textbox Position To Be the Same While Update

I am creating a calendar feature in Excel that takes inputs from a form and based on that I will put the job details into the dynamic calendar. The problem I'm facing now is that whenever I'm updating a textbox position, it will re-position to…
0
votes
0 answers

Ensure Textbox remain at same position when I update the form

I am creating an calendar features which takes inputs from a form and based of that I will assign into a dynamic calendar. The problem I'm facing now is that when I update my form the first textbox position does not remain at its original position…
0
votes
0 answers

How to run JSON parser in x64 Excel

I've inherited VBA code that in part uses Codo's code here (dated 9/4/2011). It's been working beautifully for over 10 years in x32 Excel. However it does not work in x64 Excel. From reading lot's in forums and other places it looks like the…
0
votes
1 answer

Debugging and Improving VBA Code for Worksheet Change Event in Excel

I have a VBA code in an Excel worksheet that responds to changes in specific cells. The code is supposed to handle changes in cells with data validation and should concatenate values if multiple items from the dropdown are selected. However, I'm…
0
votes
1 answer

Automatically name active worksheet, and name active cell based on active worksheet

I'm trying to run a code that merges Excel files and turns them into sheets, so far that step works perfectly. But, I would like for the sheets to be called the actual document name when they are merged into the active document, for example, once I…
alxn
  • 1
  • 2