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

Why is my Excel VBA worksheet module code being replaced with other code during a procedure?

I am working on a project where I am importing sheets from other files with the same setup. I have some code written in the worksheet module, which is expected to come with the import. I am facing an error when dealing with files placed in a shared…
Omar Adel
  • 1
  • 2
0
votes
1 answer

Two sheets Filter data results only selective column copy paste to another sheet data should not replace while pasting

Could you help me for this small issue: let me explain you I have one workbook with multiple sheets Filter apple sheet column A results one by one copy few column paste to respective given sheet in respective columns and same need to do for Orange…
0
votes
1 answer

How to filter 3 text boxes and then run a report according to them in MS Access VBA

I have 3 combo boxes: Company - cboCOMP - tblCOMPANY Category - cboCAT - tblCATEGORY FLEET NO - cboFLT - tblFLEET_NO These (1&2) are then sorted(criteria) via cboCOMP with the row source of tblFLEET_SETUP I have setup…
TravO
  • 27
  • 5
0
votes
2 answers

Adding Page Number to Table of Contents Visio [VBA]

I have supplied my code below. Right now, there is an error in my code. I want the page number to list 1,2,3,4,5 in order for each page, but it is instead listed like 5,5,5,5,5. It may be because of the code I added: Dim PageNum As String …
weaver
  • 1
0
votes
1 answer

How to send email to specific recipients if corresponding cell contains the word " expired"?

I have a list of email address but I need to send an email to only the individuals that have "expired" in their corresponding cell. On button click, it is opening multiple outlook windows. This is what I have so far: Private Sub…
0
votes
1 answer

How do I make a PowerPoint Charts automatically update?

I have a presentation that I want to loop continuously in presentation mode and automatically update the charts in the presentation. I have found that you can do this with links but as soon as you close either the .ppt or the .xls the links no…
trs11
  • 13
  • 5
0
votes
1 answer

Why has my VBA stopped working only in certain parts?

Recently the VBA has stopped working. Normally it auto-populates today's date into column B when you enter data into column C and also populates today's date into column R when you enter data in column K. I have recently messed around with…
Insider
  • 95
  • 12
0
votes
1 answer

Finding difference and Comparing dates in VBA

I am trying to write a code that takes in a date as input and checks whether or not it is later than the date defined in the code. Sub times() Dim d1 As Date n = Application.InputBox("Enter a date in mm/dd/yyyy format: ") entered_date =…
0
votes
1 answer

VBA code to search for a column data from one sheet to another and paste corresponding rows data onto first sheet

I am new to VBA and i am not able to find any solution to my problem. I have two workbooks with data. In workbook1 there is a name column A.In workbook2 there is also a name columnA and other data from column B to D. I need to search name from…
0
votes
1 answer

Copy value from another file

I am trying to copy a value from a "selected file" worksheet into an already created worksheet called "Data" in cell (I5). I wrote a code to search for number of population from previous entered country in cell (B2) in a separate worksheet called…
0
votes
0 answers

Cannot complete oreation: A table cannot overlap with a PivotTable report, query results, a table, merged cells, or an XML mapping

Hi i have error "Cannot complete oreation: A table cannot overlap with a PivotTable report, query results, a table, merged cells, or an XML mapping" What does it mean it was working till today and now it is broked. Please help me. Sub…
Salim
  • 11
  • 1
  • 5
0
votes
1 answer

check the oval shape position vba

Dears; I would like to thank you for your support. I'm in writing VBA macro to draw and color the shapes, I've got to step when I need to draw the shapes based on another position shapes, for that I need to know how I can know the shape position by…
0
votes
0 answers

Need correct syntax to declare and call HTMLHelp API in 64-bit Office and VBA7

This VBA code displays context-sensitive help in a CHM in 32-bit Microsoft Office and VBA6: Private Declare Function HtmlHelp Lib "HHCtrl.ocx" Alias "HtmlHelpA" _ (ByVal hWndCaller As Long, _ ByVal pszFile As String, _ ByVal…
0
votes
1 answer

Excel VBA: Getting run-time 1004: Method Range of object _Worksheet' failed

On my UserForm Initialize I have the following code, but am getting an "run-time 1004: Method Range of object _Worksheet' failed" error, but it doesn't specify which line. I also included my Formulas at the bellow. Private Sub…
RittenRA
  • 33
  • 6
0
votes
2 answers

Add more than 25 items in the drop down list field in MS word VBA

I have two drop down fields naming: App Language:_____ App Country: _____ App country is dependent on app language field. Every time user select a language app from drop down list (a Macro is run and) the Country field will show relevant countries…
VBAbyMBA
  • 806
  • 2
  • 12
  • 30