Dear all,,
Good day,
I am facing to run a macro in Office 2007 but it is working fine in Office 2003. Below is my coding:
i need to browse to the folder and open 1 by 1 workbook in the the folder: however, it seems this coding cannot run in office 2007. please help.
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:\Service_IPL\Generated" '<-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
With ThisWorkbook.Sheets(1)
WbCnt = WbCnt + 1
Next lCount
End If
End With
On Error GoTo 0
.ScreenUpdating = True
.DisplayAlerts = True
.EnableEvents = True
End With
Bookmarks