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

how do I change the colour of the command button on a userform with vba after the button has completely executed the code?

For example, the original colour of the text label of the button is black. I would like to change it to green after execution.n If someone can answer this more specifically for powerpoint vba, that would be great. Thanks
0
votes
0 answers

HTML Table with alternative Rows color in Access VB

I need to create a table upon clicking of a button on Access Form, which will be a body of an email sent to clients. I managed to do the table with the header format that I need, but I am unable to get the alternate rows coloring to work. Below is…
0
votes
1 answer

Pull up "Save As" box in VBA to save Chart and Range to PDF

I am trying to assign a Macro to a button that will save a plot and a few ranges of values to a single PDF file, that the user names (and chooses the save location for) themselves. So far, I can call open the save as box, from another question I saw…
Emily
  • 15
  • 3
0
votes
1 answer

Excel vba - how to use a variable inside the range function?

How do I make this a function so that I can pass "B38" as a variable? I tried putting 'startCell' inside the range function, but it barfed and I'm not clear what's required to make that work... TIA Set startCell = Range("B38") For i = 0 To 6 …
Inetquestion
  • 165
  • 1
  • 15
0
votes
4 answers

In VBA trying to create a dynamic Sumifs Formula with multiple criterias in multiple sheets

In VBA I am trying to create a sumifs formula with multiple criteria across different workbooks, but I am struggling on the syntax. WorkbookRecut.Worksheets("Summary").Activate Dim CountRows As Long Dim CountRows2 As Long CountRows =…
Drew101
  • 63
  • 6
0
votes
0 answers

Copy Pasting Syntax Problems in VBA [Edited]

Edit: I am running on Excel 2016 (if that information help) Purpose: I wanted to copy paste entire row for each participant A: ___ from one worksheet Worksheets("Sheet3")to another worksheet Worksheets("Sheet4"). based on condition "Selected"…
Glenn98
  • 1
  • 1
0
votes
1 answer

Webscraping innertext in id

Inner text under id is not printing. Sub JJ() Dim IE As New SHDocVw.InternetExplorer Dim hdoc As MSHTML.HTMLDocument Dim HEL, HBE As MSHTML.IHTMLElement Dim HBEs As MSHTML.IHTMLElementCollection Dim ha, hb, hc, hd, he, hf, hg, hh, hi, hj As…
AAdi
  • 15
  • 4
0
votes
1 answer

Remove formulas from Excel sheet

I'm working on one project where I'm using VBA and inbuilt formulas in Excel Macro file. In the end want to remove formulas once it has done processing and calculating. Option 1:- sht.UsedRange.Value2 = sht.UsedRange.Value2 Option 2:- rng.Value2 =…
1S1a4m9
  • 27
  • 7
0
votes
2 answers

Dynamically adjust range based on last column in vba

I have a table in excel where i am inserting some column, because of that last column is getting changed, I have to detect the last column and set it as a range in vba I have written code to find the last column and convert it to alphabet, however i…
om prakash
  • 29
  • 1
  • 7
0
votes
1 answer

How to write range with variable in vba

I am unable to write vba code where mentioned range has variable which is changing with every iteration. Here is a code Letter = "H" LastRow = Cells(Rows.Count, 10).End(xlUp).Row Set Rng = Range("J5:J" & LastRow) For Each cell In Rng If…
om prakash
  • 29
  • 1
  • 7
0
votes
0 answers

Access VBA Runtime error 3070: ...does not recognize Assgnrst.MemberID as a valid fieldname or expression

I get this error with the FindFirst statement. Code is below. If Assgnrst.CompID <> 0 Then ComID = Assgnrst!CompID!Value Debug.Print Assgnrst.MemberID, ComID FindFirststr = "Assgnrst.MemberID = " & ComID & "" …
0
votes
0 answers

Runtime Error '3078': The Microsoft Access database engine cannot find the input table

I need to update a table that is based on a query. The query (tmp_Assign) is a straight-forward, single table query to pull location and date specific data. The code that is causing the error is below. Set Assgnrst =…
0
votes
1 answer

Excel VBA Communicating with Jira using Isolated Site Minder cookies using REST

I have inherited an Excel Tracker sheet and the code originally was created by someone else who has since left the company. We have an Excel VBA Tracker sheet which communicates with Jira and used to work fetching projects and issues without any…
0
votes
1 answer

I Don't want to wait for whole page to be loaded while automating browser using selenium and Excel VBA

Iam Trying to automate Google Chrome using Excel VBA and Selenium But the website Iam using for accessing data loads a lot of ads before fully loading! Data Website Link The element required for triggering for next command is present even before 1…
Decode It
  • 1
  • 1
0
votes
1 answer

function Now() in ActiveWorkbook.SaveAs

I can't figure it out why macro everytime save file with filename .xl&somedigits like filename.xl105 with this code: ActiveWorkbook.SaveAs ("C:\Users\username\Desktop\" & "Fname " & Format(Now(), "DD.MM.YYYY" & ".xlsm")), _ …
angelares
  • 3
  • 2