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

Can I import a public enum in VBA code as a list for table field in Access?

Let's imagine I have the following VBA code in a Microsoft Access database. Option Compare Database Public Enum testdata foo = 0 bar = 1 baz = 2 End Enum Just for context, I'm declaring this in a module like so: Now, what I want to…
puppydrum64
  • 1,598
  • 2
  • 15
0
votes
1 answer

Windows API in a Sub Function [VBA]

I am new to VBA therefore please excuse me in advance if my question is silly. That said, I have the following Windows API: Private Declare PtrSafe Function IsIconic Lib "user32" (ByVal hWnd As LongPtr) As Integer and inside the module where we…
George Smith
  • 415
  • 8
  • 25
0
votes
1 answer

VBA: Subroutine to replicate the "Remove Duplicates" command is crashing excel

I'm new to VBA and have been writing subroutines of my own to practice. I thought it would be an interesting exercise to try to replicate the "remove duplicates" command with some rudimentary code. To do this, I used a "do until" loop nested in…
0
votes
1 answer

Display all e-mails with certain category in Outlook

I would like to create a macro that will display all e-mails in certain category. So far I am using Sub GDPR() Dim myOlApp As New Outlook.Application txtSearch = "category:=(""Personal Data"")" myOlApp.ActiveExplorer.Search txtSearch,…
0
votes
1 answer

Editing listbox item

So i have a listbox that displays all the orders entered in the Order table using a select sql query. Now i also want to add the ability to edit the items from the listbox, i see the right click edit list item option but when i click it, it just…
0
votes
0 answers

How to Vlookup with Filter data

I have a two sheets one sheet have a data another sheet have a reference supplier list. I need to vlookup with specific suppliers. First i filter the suppliers. After that i need to perform Vlookup funciton. Please if any once help me on this. Sub…
0
votes
1 answer

Vba find "-" by using seach function and extract only numbers fix errors

Could you please help me on below error in vba. Formula works but there are error. My scenario is need to extract in between number (between two "-") Ite1-223466678-ghtrdhjuyr321 Ite-654354477-hjuyt- Dftehh-767678765-4yutiuy Extract only this 9…
Rahul2020
  • 33
  • 6
0
votes
2 answers

How to use Target Address for multiple rows in VBA?

Need your guidance on how If i can apply Target Address & its Value for multiple rows. I am new to VBA, The below code is working for 1 Row as of now, but how can i can apply for multiple rows. Let's say, In a range from B4 to B10, if i select B7,…
log_anupam
  • 3
  • 1
  • 3
0
votes
0 answers

Outputting content from immediate window into worksheet

I have the following code, which i want to output on the worksheet, instead of the immediate window. Can someone help me with this? Sub Fly() Dim r As Integer Dim c As Integer Dim Number As Single Number = 10002 ReDim…
John
  • 1
0
votes
1 answer

How to move text between tags to new document word from excel vba

I have a long list of word documents which all have three pages. now i want every fist page in document 1, every 2nd page in document 2 and every 3rd page in document 3. I have tags on every page in my word document but every page has the same tag.…
0
votes
1 answer

Word VBA- Deleting row that is bookmarked if nothing is entered in textboxx25 - userform

I have textboxx25 setup so that a user can enter text in it in a userform. For some reason the code below is still deleting the row even if something is entered in the textbox, anyone have any suggestions? The bookmark (bmrow1) is bookmarked to an…
mr-walrus
  • 31
  • 3
0
votes
0 answers

How do I use different currencies VBA

I'm making a price scraper using VBA, so I can put the values nicely organized in Excel. But this scraper takes different currencies. When it puts a value with $ in front of it, it defaults to a currency cell, which is good. But when I put for…
JasperDG
  • 137
  • 1
  • 3
  • 7
0
votes
1 answer

How to add autofill to all the textboxes

I am new to vba and I want to learn. Please help me with the following: I have this application(see the picture) which I use to enter data in a worksheet (it is more easy to use compared to completing manually). It is basically an inventory…
0
votes
0 answers

Extract a JSON DATA table in html using VBA; converting Apps Script into VBA

I want to retrieve a table from the URL of https://s.cafef.vn/screener.aspx#data using VBA. This task is difficult because the table contains JSON data embedded in an html file, but it was so kind of Tanaike, an GAS expert who helped me to create…
Cao Doremi
  • 91
  • 6
0
votes
1 answer

Find set of strings in a cell and copy ONLY found strings to next cell by VBA

I have a variable set of strings inside the cells to be found in a sheet, like "horse" "apple" "apple/2" "cat", etc. I need only copy the found string and paste it to next cell. For example.: A cell in column B is "Today the horse is happy". So i…
Black Mamba
  • 247
  • 1
  • 12