I have almost no VBA knowledge, so hopefully this is an easy error for real experts to spot!
My code below is working OK, except that the file "Output.xls" is being created in the PC's Documents folder rather in the specified folder. I can't figure out why!
Thanks in advance for your help!
--------
Sub AllFiles()
Dim folderPath As String
Dim filename As String
Dim wb As Workbook
folderPath = "C:\Output\Macrofiles\" 'change to suit
If Right(folderPath, 1) <> "\" Then folderPath = folderPath + "\"
Set OutputBook = Workbooks.Add '' Creates the output.xls workbook for pasting all the data into
With OutputBook
.SaveAs filename:="Output.xls"
End With
filename = Dir(folderPath & "*.xls")
Do While filename <> ""
Application.ScreenUpdating = False
Set wb = Workbooks.Open(folderPath & filename)
'Call a subroutine here to operate on the just-opened workbook
Call DataGrabber
wb.Close False
filename = Dir
Loop
Application.ScreenUpdating = True
End Sub
Bookmarks