Compile error when using 64bit version of Excel
  • KB ID: AA-00724
  • Created: 01/10/2014 12:58 PM
  • Updated: 03/07/2014 1:01 PM
  • Views: 9158
  • 0 Ratings

Symptoms

If you are using the XML Macro (XMLExport) for LCM Import Launcher and you have been switching to a 64bit version of Excel you might get the following error:


German:
Fehler beim Kompilieren:

Der Code in diesem Projekt muss für die Verwendung auf
64-Bit-Systemen aktualisiert werden. Überarbeiten und aktualisieren Sie
Declare-Anweisungen, und markieren Sie sie mit dem PtrSafe-Attribut.


Cause

Microsoft has changed the method to declare functions for 64bit versions of VBA


Resolution

Change the following lines within the Excel Macro (General > Declarations) using Alt+F11 to get to the code

Private Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal hMem As Long)
Private Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long
Private Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long
Private Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long

to

#If Win64 Then
  Private Declare PtrSafe Sub CoTaskMemFree Lib "ole32.dll" (ByVal hMem As Long)
  Private Declare PtrSafe Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long
  Private Declare PtrSafe Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long
  Private Declare PtrSafe Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long
#Else
  Private Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal hMem As Long)
  Private Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long
  Private Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long
  Private Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long
#End If

and safe the macro/project resp. the Excel sheet.


More Information

Microsoft KB:
http://msdn.microsoft.com/en-us/library/office/gg278832.aspx


Keywords

64bit, PtrSafe, Excel, Macro, XMLExport


Products

LCM5, LCM6

Feedback

Did you find this article helpful?

© 2000-2018 Brainware Consulting & Development AG     Impressum / Legal Notice  |  Datenschutz / Privacy Policy