3 Replies Latest reply on Nov 12, 2015 7:11 AM by Jean Stassen

    How to solve 64-bit compile error ?

    Jean Stassen

      When starting "SaveAsPDFwFolderSelection.swp" I get errorwindow below

      How can i solve this? I'm a BEGINNER in API and learning day by day

       

      Please find attached the macro wich i used and downloaded from the internet.

      btw I'm using SW2015 SP4.0

        • Re: How to solve 64-bit compile error ?
          Matt Martens

          The issue is the macro calls for the use of 32-bit functions from the Shell object library. You need to add PtrSafe to each of the 4 Function declarations in the "modBrowseToFolder" module.

           

          Private Declare PtrSafe Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam 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

          Private Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long

           

          That doesn't guarantee that it will work but will get you to a point where the code will compile.

            • Re: How to solve 64-bit compile error ?
              Simon Turner

              All the Longs need changing to LongPtr as well. For example:

               

               

              Private Type BROWSEINFO

                hOwner As LongPtr

                pidlRoot As LongPtr

                pszDisplayName As String

                lpszTitle As String

                ulFlags As Long

                lpfn As LongPtr

                lParam As LongPtr

                iImage As Long

              End Type

               

              Private Declare PtrSafe Function SHBrowseForFolder Lib "shell32.dll" Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As LongPtr

              Private Declare PtrSafe Function SHGetPathFromIDList Lib "Shell32" Alias "SHGetPathFromIDListA" (ByVal pidList As LongPtr, ByVal lpBuffer As String) As Long

              Private Declare PtrSafe Sub CoTaskMemFree Lib "ole32" (ByVal hMem As LongPtr)

              Private Declare PtrSafe Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As LongPtr, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As LongPtr