title: VBA - Office 365 x64 bit - Completely crashing
body: <p>This is my first time asking for any help on stack overflow, let alone commenting so please be gentle with me :)</p>
  
  <p>I am at a loss with this one, I will give as much information as possible.</p>
  
  <p><strong><em>Issue</em></strong></p>
  
  <p>I would like to preface, this code does not cause any crashes on the latest update of 0365, only on Version 1807 &amp; earlier. It also does not crash on the 32 bit version at all which makes me think it's a 64 bit issue. My client cannot update from this version either so simply asking them to update is not going to be able to happen.</p>
  
  <p>I have narrowed the crashing down to this particular section.</p>
  
  <pre><code>Public Function GetSpecialFolder(CSIDL As Long) As String
  '*******************************************************************************
  '*  Function:     GetSpecialFolder
  '*  Purpose:      Wraps the apis to retrieve folders such as My Docs etc.
  
  '*******************************************************************************
        Dim idlstr                   As Long
        Dim sPath                         As String
        Dim IDL                           As ITEMIDLIST
        Const MAX_LENGTH = 260
  
        'Fill the IDL structure with the specified folder item.
        On Error GoTo GetSpecialFolder_Error
  
        idlstr = SHGetSpecialFolderLocation _
            (0, CSIDL, IDL)
  
        If idlstr = 0 Then
          'Get the path from the IDL list, and return the folder adding final "\".
          sPath = Space$(MAX_LENGTH)
          **idlstr = SHGetPathFromIDList(ByVal IDL.mkid.cb, ByVal sPath)**
          If idlstr Then
            GetSpecialFolder = Left$(sPath, InStr(sPath, Chr$(0)) _
                - 1) &amp; "\"
          End If
        End If
  
      procExit:
        On Error Resume Next
        Exit Function
  
      GetSpecialFolder_Error:
        CommonErrorHandler lngErrNum:=Err.Number, strErrDesc:=Err.Description, _
          strProc:="GetSpecialFolder", strModule:="modWinAPI", lngLineNum:=Erl
        Resume procExit
  
      End Function
  </code></pre>
  
  <p>And here is the declaration </p>
  
  <pre><code>'File system
  Public Declare PtrSafe Function SHGetSpecialFolderLocation Lib "shell32.dll" _
      (ByVal hwndOwner As Long, ByVal nFolder As Long, pidl As ITEMIDLIST) As Long
  
  Public Declare PtrSafe Function SHGetPathFromIDList Lib "shell32.dll" _
      Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long
  
  Private Declare PtrSafe Function GetTempPath Lib "kernel32" _
      Alias "GetTempPathA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
  
  Private Declare PtrSafe Function ShellExecute Lib "shell32.dll" _
      Alias "ShellExecuteA" (ByVal hwnd As LongPtr, ByVal lpOperation As String, _
      ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, _
      ByVal nShowCmd As Long) As LongPtr
  
  Private Type ITEMIDLIST
  mkid                              As ShortItemId
  End Type
  
  Private Type ShortItemId
    cb                                As Long
    abID                              As Byte
  End Type
  </code></pre>
  
  <p>I have tried adding Long<strong>Ptr</strong> as suggested in documents I've found online but it hasn't helped.</p>
  
  <p>Can anyone help me?</p>
  
  <p>Thanks!</p>