+ Reply to Thread
Results 1 to 6 of 6

How to determine if excel is 32 bit or 64 bit

Hybrid View

  1. #1
    Registered User
    Join Date
    01-14-2013
    Location
    Jupiter
    MS-Off Ver
    Excel 2013
    Posts
    78

    How to determine if excel is 32 bit or 64 bit

    I have a declare function that only seems to work with 64 bit excel and i want it to work with both 32 and 64. I was thinking of using an "IF" statement to determine which function to run. However, I don't know how to determine if its 32 or 64.

    Below is the Declare Function and the code that runs on Userform_Initialize:
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
    (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
    (ByVal hWnd As Long, ByVal nIndex As Long) As Long
    Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
    (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    Private Declare Function SetLayeredWindowAttributes Lib "user32" _
    (ByVal hWnd As Long, ByVal crey As Byte, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
    
    Private Const GWL_EXSTYLE = (-20)
    Private Const WS_EX_LAYERED = &H80000
    Private Const LWA_ALPHA = &H2&
    Public hWnd As Long
    
    Private Sub UserForm_Initialize()
           Dim bytOpacity As Byte
        bytOpacity = 220 ' variable keeping opacity setting
        hWnd = FindWindow("ThunderDFrame", Me.Caption)
        Call SetWindowLong(Me.hWnd, GWL_EXSTYLE, GetWindowLong(Me.hWnd, GWL_EXSTYLE) Or WS_EX_LAYERED)
        Call SetLayeredWindowAttributes(Me.hWnd, 0, bytOpacity, LWA_ALPHA)
    End SUb

  2. #2
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: How to determine if excel is 32 bit or 64 bit

    Try this

    =INFO("OSVERSION")
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  3. #3
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: How to determine if excel is 32 bit or 64 bit

    You may use conditional compilation:
    #If VBA7 Then
       Private Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" _
                                           (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPtr
       Private Declare PtrSafe Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
                                           (ByVal hWnd As LongPtr, ByVal nIndex As Long) As Long
       Private Declare PtrSafe Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
                                           (ByVal hWnd As LongPtr, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
       Private Declare PtrSafe Function SetLayeredWindowAttributes Lib "user32" _
                                           (ByVal hWnd As LongPtr, ByVal crey As Byte, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
       Public hWnd                     As LongPtr
    #Else
       Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
                                           (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
       Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
                                           (ByVal hWnd As Long, ByVal nIndex As Long) As Long
       Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
                                           (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
       Private Declare Function SetLayeredWindowAttributes Lib "user32" _
                                           (ByVal hWnd As Long, ByVal crey As Byte, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
       Public hWnd                     As Long
    #End If
    
    Private Const GWL_EXSTYLE = (-20)
    Private Const WS_EX_LAYERED = &H80000
    Private Const LWA_ALPHA = &H2&
    
    Private Sub UserForm_Initialize()
           Dim bytOpacity As Byte
        bytOpacity = 220 ' variable keeping opacity setting
        hWnd = FindWindow("ThunderDFrame", Me.Caption)
        Call SetWindowLong(Me.hWnd, GWL_EXSTYLE, GetWindowLong(Me.hWnd, GWL_EXSTYLE) Or WS_EX_LAYERED)
        Call SetLayeredWindowAttributes(Me.hWnd, 0, bytOpacity, LWA_ALPHA)
    End Sub
    Last edited by Izandol; 03-05-2014 at 01:07 PM.
    • Please remember to mark threads Solved with Thread Tools link at top of page.
    • Please use code tags when posting code: [code]Place your code here[/code]
    • Please read Forum Rules

  4. #4
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,789

    Re: How to determine if excel is 32 bit or 64 bit

    Perhaps this macro written by Richard Schollar?

    Sub test()
    Dim bIs64Bit As Boolean
    #If win64 Then
        bIs64Bit = True
    #End If
    MsgBox "This is 64bit office: " & bIs64Bit
    End Sub
    Alf

  5. #5
    Registered User
    Join Date
    01-14-2013
    Location
    Jupiter
    MS-Off Ver
    Excel 2013
    Posts
    78

    Re: How to determine if excel is 32 bit or 64 bit

    Thank you all! I ended up using Izandol's code and it works great.

  6. #6
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: How to determine if excel is 32 bit or 64 bit

    You are welcome.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Problem determine last row. Some files are excel 97 some are excel 2007
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-14-2011, 05:15 PM
  2. Determine if Excel is already running...
    By JWM6 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-16-2007, 11:56 AM
  3. How to determine the number in excel?
    By Eric in forum Excel General
    Replies: 1
    Last Post: 03-13-2006, 02:35 AM
  4. How to determine following function in Excel?
    By Eric in forum Excel General
    Replies: 5
    Last Post: 03-05-2006, 10:10 PM
  5. Determine excel language
    By DS NTE in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-27-2005, 02:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1