title: VBA / Macro upgraded from 32 bit to 64 bit
body: <p>I have been upgraded from 32bit to 64 bit and my macro to merge and arrange files in a folder does not work any more, not a VBA user so am pretty much stuck and would appreciate help getting the marco to work ?</p>
  
  <pre><code>Option Explicit
  
   '32-bit API declarations
  Declare Function SHGetPathFromIDList Lib "shell32.dll" _
  Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal _
  pszpath As String) As Long
  
  Declare Function SHBrowseForFolder Lib "shell32.dll" _
  Alias "SHBrowseForFolderA" (lpBrowseInfo As BrowseInfo) _
  As Long
  
  Public 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
  
  Function GetDirectory(Optional msg) As String
      On Error Resume Next
      Dim bInfo As BrowseInfo
      Dim path As String
      Dim r As Long, x As Long, pos As Integer
  
       'Root folder = Desktop
      bInfo.pIDLRoot = 0&amp;
  
       'Title in the dialog
      If IsMissing(msg) Then
          bInfo.lpszTitle = "Please select the folder of the excel files to copy."
      Else
          bInfo.lpszTitle = msg
      End If
  
       'Type of directory to return
      bInfo.ulFlags = &amp;H1
  
       'Display the dialog
      x = SHBrowseForFolder(bInfo)
  
       'Parse the result
      path = Space$(512)
      r = SHGetPathFromIDList(ByVal x, ByVal path)
      If r Then
          pos = InStr(path, Chr$(0))
          GetDirectory = Left(path, pos - 1)
      Else
          GetDirectory = ""
      End If
  End Function
  
  Sub CombineFiles()
      Dim path            As String
      Dim FileName        As String
      Dim LastCell        As Range
      Dim Wkb             As Workbook
      Dim ws              As Worksheet
      Dim ThisWB          As String
  
      Application.DisplayAlerts = False
  
  
      ThisWB = ThisWorkbook.Name
      Application.EnableEvents = False
      Application.ScreenUpdating = False
      path = GetDirectory
      FileName = Dir(path &amp; "\*.xlsx", vbNormal)
      Do Until FileName = ""
          If FileName &lt;&gt; ThisWB Then
              Set Wkb = Workbooks.Open(FileName:=path &amp; "\" &amp; FileName)
              For Each ws In Wkb.Worksheets
                  If ws.Visible = xlSheetHidden Then
                  Else
                      ws.Copy After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count)
                  End If
              Next ws
              Wkb.Close False
          End If
          FileName = Dir()
      Loop
      Application.EnableEvents = True
      Application.ScreenUpdating = True
  
      Set Wkb = Nothing
      Set LastCell = Nothing
  
      Call Sort_Tabs
  
      Call Hide_create_tab
  
      Call Select_all_sheets
  
      Application.Dialogs(xlDialogSaveAs).Show "Enter MCR file name"
  
  
      Application.DisplayAlerts = True
  
  End Sub
  
  
  Sub Sort_Tabs()
       'declare our variables
      Dim i, j As Integer
      Dim iNumSheets As Integer
       'find the number of sheets to work with
      iNumSheets = ActiveWorkbook.Sheets.Count
       'turn off screen updating to prevent screen flicker
      Application.ScreenUpdating = False
       'work through our number of sheets
      For i = 1 To iNumSheets - 1
          For j = i + 1 To iNumSheets
               'check the name of the sheet regardless of case
              If UCase(Sheets(i).Name) &gt; UCase(Sheets(j).Name) Then
                   'set where to move the sheet to
                  Sheets(j).Move before:=Sheets(i)
              End If
               'do next sheet
          Next j
      Next i
       'let the screen update
      Application.ScreenUpdating = True
  End Sub
  
  Sub Hide_create_tab()
  
  Sheets("Create MCR").Select
  ActiveSheet.Visible = False
  
  End Sub
  
  Sub Select_all_sheets()
  
  Dim ws As Worksheet
  For Each ws In Sheets
      If ws.Visible Then ws.Select (False)
  Next
  End Sub
  </code></pre>