hi all,
i facing a problem here. i want to make the marco to let all the excel files in 1 folder auto open.
below is the coding,
i try many pc, all are function only 1 pc cannot find the application .file search and pop up an error. i attach the bug of print screen.
can someome please help me, why some pc do not have any problem but only 1 pc has problem. i use same marco file. the microsoft office version is 2002. has something wrong with the coding or excel settings?
please assist.
Sub Get_Value_From_All()
Dim lCount As Long
Dim wbResults As Workbook
Dim wbThis As Workbook
Dim dblValue As Double
Dim WbCnt As Long
With Application
.ScreenUpdating = False
.DisplayAlerts = False
.EnableEvents = False
On Error Resume Next
Set wbThis = ThisWorkbook
dblValue = 0
WbCnt = 0
With .FileSearch
.NewSearch
.LookIn = "C:\MyDocuments\TestResults" '<-Change path to suit
.FileType = msoFileTypeExcelWorkbooks
If .Execute > 0 Then 'Workbooks in folder
For lCount = 1 To .FoundFiles.Count 'Loop through all.
'Open Workbook x and Set a Workbook variable to it
Set wbResults = Workbooks.Open(Filename:=.FoundFiles(lCount), UpdateLinks:=0)
'your code here
End If
WbCnt = WbCnt + 1
Next lCount
End With
MsgBox "Checked " & WbCnt & " workbooks, total value is: " & dblValue
On Error GoTo 0
.ScreenUpdating = True
.DisplayAlerts = True
.EnableEvents = True
End With
End Sub
Bookmarks