goss
Active Member
- Joined
- Feb 2, 2004
- Messages
- 372
Hi all,
Using Excel 2010
I also have Excel 2013 Beta installed
My code returns the error
I am using FileSystemObject and I have reference set to Microsoft Scripting Runtime.
I made sure the file reported does exist in the location specified.
The files in the folder are in .xls format
My debug line returns the first filename as expected
Debug points to this line
Any idea what might be wrong?
thx
w
Using Excel 2010
I also have Excel 2013 Beta installed
My code returns the error
Run-time error '1004': File could not be found. Check the spelling of the file name and verify that the file location is correct...
I am using FileSystemObject and I have reference set to Microsoft Scripting Runtime.
I made sure the file reported does exist in the location specified.
The files in the folder are in .xls format
My debug line returns the first filename as expected
Debug points to this line
Code:
Workbooks.Open (oFile.Name)
Any idea what might be wrong?
thx
w
Code:
'Declare variables
Dim wb As Workbook
Dim wbCurr As Workbook
Dim ws As Worksheet
Dim FSO As FileSystemObject
Dim oFolder As Folder
Dim oFile As File
Dim rng As Range
Dim rngData As Range
Dim rngDest As Range
Dim rngNew As Range
Dim rngCrit As Range
Dim arrCrit
Dim varrFilter As Variant
Dim strPathIn As String
Dim strPathOutput As String
Dim strFileOutput As String
Dim strOpFile As String
Dim lngRows As Long
Dim lngRowsCriteria As Long
Dim i As Long
Dim FileFormatValue As Long
'Initialize variables
Set wb = ThisWorkbook
strPathIn = "C:\Countries\" '<-Change as needed
'Instantiate FileSystemObject
Set FSO = New FileSystemObject
'Loop through the files in the folder
For Each oFile In FSO.GetFolder(strPathIn).Files
Debug.Print oFile.Name
Workbooks.Open (oFile.Name)
strOpFile = ActiveWorkbook.Name
Windows(strOpFile).Activate
Set wbCurr = Application.ActiveWorkbook
Set ws = wbCurr.Worksheets("Sheet1")