title: Use VBA on both 32 bit and 64 bit for Excel 2013
body: <p>Have the following code that I am unable to compile, hope someone can point me in the right direction.</p>
  
  <p>My code is used to open the browseFolder, errors on <code>.hOwner = hWndAccessApp</code>  </p>
  
  <pre><code>Option Explicit
  
  #If VBA7 Then
      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.dll" Alias "SHGetPathFromIDListA" _
          (ByVal pidl As LongPtr, ByVal pszPath As String) As Boolean
  #Else
      Private Type BROWSEINFO
          hOwner As Long
          pidlRoot As Long
          pszDisplayName As String
          lpszTitle As String
          ulFlags As Long
          lpfn As Long
          lParam As Long
          iImage As Long
      End Type
  
      Private Declare Function SHBrowseForFolder Lib "shell32.dll" Alias "SHBrowseForFolderA" _
          (lpBrowseInfo As BROWSEINFO) As Long
      Private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" _
          (ByVal pidl As Long, ByVal pszPath As String) As Boolean
  #End If
  
  Private Const BIF_RETURNONLYFSDIRS = &amp;H1
  
  Public Function BrowseFolder(Optional szDialogTitle As String) As String
      Dim X As Long, bi As BROWSEINFO, dwIList As Long
      Dim szPath As String, wPos As Integer
  
      With bi
          .hOwner = hWndAccessApp
          .lpszTitle = szDialogTitle
          .ulFlags = BIF_RETURNONLYFSDIRS
      End With
  
      dwIList = SHBrowseForFolder(bi)
      szPath = Space$(512)
      X = SHGetPathFromIDList(ByVal dwIList, ByVal szPath)
  
      If X Then
          wPos = InStr(szPath, Chr(0))
          BrowseFolder = Left$(szPath, wPos - 1)
      Else
          BrowseFolder = vbNullString
      End If
  End Function
  </code></pre>