The problem of opening an Excel Mav on a 64-bit system

sofas

Active Member
Joined
Sep 11, 2022
Messages
468
Office Version
  1. 2019
Platform
  1. Windows
VBA Code:
Option Explicit

Public Declare Function QueryPerformanceCounter Lib "kernel32" (x As Currency) As Boolean
Public Declare Function QueryPerformanceFrequency Lib "kernel32" (x As Currency) As Boolean

Public srch As String
Public Const RDepart = 12

Public Dep As Currency, Fin As Currency, Freq As Currency
Public sDossierDepart As String

Public Declare Function SHCreateDirectoryEx Lib "Shell32.dll" Alias "SHCreateDirectoryExA" _
                                            (ByVal hwnd As Long, _
                                             ByVal pszPath As String, _
                                             ByVal lngsec As Long) As Long


Code:
End Type


Private Declare Function FindClose Lib "kernel32" (ByVal hFindFile As Long) As Long
Private Declare Function FindFirstFile Lib "kernel32" _
                                       Alias "FindFirstFileA" _
                                       (ByVal lpFileName As String, lpFindFileData As WIN32_FIND_DATA) As Long
Private Declare Function FindNextFile Lib "kernel32" _
                                      Alias "FindNextFileA" _
                                      (ByVal hFindFile As Long, lpFindFileData As WIN32_FIND_DATA) As Long
Private Declare Function lstrlen Lib "kernel32" Alias "lstrlenW" (ByVal lpString As Long) As Long
Private Declare Function PathMatchSpec Lib "shlwapi" _
                                       Alias "PathMatchSpecW" _
                                       (ByVal pszFileParam As Long, ByVal pszSpec As Long) As Long

Private FP As FILE_PARAMS
Private iNbDossier As Long


 

Attachments

  • Screenshot 2023-01-13 014709.png
    Screenshot 2023-01-13 014709.png
    33.1 KB · Views: 10
Last edited:

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
On a 64-bit system, there can be compatibility issues when trying to open a Microsoft Excel macro-enabled workbook (XLSM) that was created on a 32-bit system. This is because the macros in the workbook may reference 32-bit dynamic-link libraries (DLLs) that are not present on the 64-bit system.

To open the workbook, you can try the following solutions:

  • Open the workbook in the 32-bit version of Microsoft Excel.
  • Re-create the macros in the workbook on the 64-bit system.
  • Use the "Microsoft Excel Macro-Enabled Workbook" format (XLSM) instead of the "Microsoft Excel Workbook" format (XLSX)
  • Use a third-party tool to convert the workbook from a 32-bit to 64-bit format.
Alternatively, you can run the workbook in a virtual machine on a 32 bit system or use a compatibility mode on your 64-bit system.

It is also important to note that certain Excel VBA functions and properties may also not be available on 64-bit systems, and may need to be replaced with their 64-bit equivalents or alternative functions.
 
Upvote 0
I can't test this and not all of those functions exist in the MS 64bit API docs, but it should be something like this as best I can tell:

VBA Code:
Type LARGE_INTEGER
      LowPart As Long
      HighPart As Long
End Type
#If VBA7 Then
   Declare PtrSafe Function QueryPerformanceCounter Lib "kernel32" (lpPerformanceCount As LARGE_INTEGER) As Long
   Declare PtrSafe Function QueryPerformanceFrequency Lib "kernel32" (lpFrequency As LARGE_INTEGER) As Long
   Declare PtrSafe Function FindClose Lib "kernel32" (ByVal hFindFile As LongPtr) As Long
   Declare PtrSafe Function FindFirstFile Lib "kernel32" Alias "FindFirstFileA" (ByVal lpFileName As String, lpFindFileData As WIN32_FIND_DATA) As LongPtr
   Declare PtrSafe Function FindNextFile Lib "kernel32" Alias "FindNextFileA" (ByVal hFindFile As LongPtr, lpFindFileData As WIN32_FIND_DATA) As LongPtr
   Declare PtrSafe Function lstrlen Lib "kernel32" Alias "lstrlenW" (ByVal lpString As LongPtr) As Long
   Declare Function PathMatchSpec Lib "shlwapi" _
                                          Alias "PathMatchSpecW" _
                                          (ByVal pszFileParam As LongPtr, ByVal pszSpec As LongPtr) As Long
   Public Declare PtrSafe Function SHCreateDirectoryEx Lib "Shell32.dll" Alias "SHCreateDirectoryExA" _
                                               (ByVal hwnd As LongPtr, _
                                                ByVal pszPath As String, _
                                                ByVal lngsec As Long) As Long
#Else
   Public Declare Function QueryPerformanceCounter Lib "kernel32" (x As Currency) As Boolean
   Public Declare Function QueryPerformanceFrequency Lib "kernel32" (x As Currency) As Boolean
   Public Declare Function SHCreateDirectoryEx Lib "Shell32.dll" Alias "SHCreateDirectoryExA" _
                                               (ByVal hwnd As Long, _
                                                ByVal pszPath As String, _
                                                ByVal lngsec As Long) As Long
   Private Declare Function FindClose Lib "kernel32" (ByVal hFindFile As Long) As Long
   Private Declare Function FindFirstFile Lib "kernel32" _
                                          Alias "FindFirstFileA" _
                                          (ByVal lpFileName As String, lpFindFileData As WIN32_FIND_DATA) As Long
   Private Declare Function FindNextFile Lib "kernel32" _
                                         Alias "FindNextFileA" _
                                         (ByVal hFindFile As Long, lpFindFileData As WIN32_FIND_DATA) As Long
   Private Declare Function lstrlen Lib "kernel32" Alias "lstrlenW" (ByVal lpString As Long) As Long
   Private Declare Function PathMatchSpec Lib "shlwapi" _
                                          Alias "PathMatchSpecW" _
                                          (ByVal pszFileParam As Long, ByVal pszSpec As Long) As Long
#End If

There are probably other changes in the rest of the code that will be needed based on the changed types in the 64 bit declarations.
 
Upvote 0

Forum statistics

Threads
1,214,864
Messages
6,121,981
Members
449,058
Latest member
oculus

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top