Hi Brilliant People,
I know there have been posts for workarounds, but I can't figure out how to apply to my code, because I am a complete novice when it comes to vb. Years ago, I created this code to 'mine' a bunch of excel files in a directory and extract a data table I'd hide in the background of excel workbooks. It worked perfectly and now with the powers that be killing application.filesearch, I can't seem to get a replacement working.
I've read there are a few workarounds, but I can't seem to get it working. Was wondering if anyone can help me?
Thanks,
Cam
I know there have been posts for workarounds, but I can't figure out how to apply to my code, because I am a complete novice when it comes to vb. Years ago, I created this code to 'mine' a bunch of excel files in a directory and extract a data table I'd hide in the background of excel workbooks. It worked perfectly and now with the powers that be killing application.filesearch, I can't seem to get a replacement working.
Code:
Private Sub CommandButton1_Click()
'Turn off Warnings
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Dim MyDir As String
Dim strPath As String
Dim vaFileName As Variant
Dim i As Integer
Dim this_workbook As String
Dim settings_row As Integer
Dim row_number As Integer
Dim Current_Workbook As String
Dim FileName As String
Dim SaveFile As String
MyDir = ActiveWorkbook.Path ' current path
strPath = MyDir & "/Test_Process" ' files subdir
With Application.FileSearch
.NewSearch
.LookIn = strPath
.SearchSubFolders = False
.FileName = ".xls"
If .Execute > 0 Then
For Each vaFileName In .FoundFiles
' open the workbook
Workbooks.Open vaFileName, Password:=""
With ActiveWorkbook
Current_Workbook = ActiveWorkbook.Name
'Extract all Occupancy Data
row_number = 6
Sheets("Data_Extract").Visible = True
Sheets("Data_Extract").Select
ActiveSheet.Range("A2:M9").Select
Selection.Copy
Workbooks("TEST_PROCESS_REPORT.xls").Activate
settings_row = ActiveWorkbook.Sheets("Occupancy_Data").Range("a50000").End(xlUp).Row + 1
With ActiveWorkbook
.Sheets("Occupancy_Data").Select
ActiveSheet.Range("a" & settings_row).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End With
Windows(Current_Workbook).Activate
.Close
End With
Next
End If
End With
Application.ScreenUpdating = True
End Sub
I've read there are a few workarounds, but I can't seem to get it working. Was wondering if anyone can help me?
Thanks,
Cam