VBA learner ITG
Active Member
- Joined
- Apr 18, 2017
- Messages
- 272
- Office Version
- 365
- Platform
- Windows
- MacOS
Hi all,
I found the below code on another forum that will loop through files on a normal windows machine with a network location.
However I am using a mac and i was wondering if anyone knows how to amend the code so it works on a mac.
Sub Macro1()
'//Change the path to the main folder, accordingly
Call RecursiveFolders("C:\Path")
End Sub
Sub RecursiveFolders(ByVal MyPath As String)
Dim FileSys As Object
Dim objFolder As Object
Dim objSubFolder As Object
Dim objFile As Object
Dim wkbOpen As Workbook
Set FileSys = CreateObject("Scripting.FileSystemObject")
Set objFolder = FileSys.GetFolder(MyPath)
Application.ScreenUpdating = False
For Each objSubFolder In objFolder.SubFolders
For Each objFile In objSubFolder.Files
Set wkbOpen = Workbooks.Open(Filename:=objFile)
'//Change the name of your macro, accordingly
Call Macro2
wkbOpen.Close savechanges:=True
Next
Call RecursiveFolders(objSubFolder.Path)
Next
Application.ScreenUpdating = True
End Sub
I found the below code on another forum that will loop through files on a normal windows machine with a network location.
However I am using a mac and i was wondering if anyone knows how to amend the code so it works on a mac.
Sub Macro1()
'//Change the path to the main folder, accordingly
Call RecursiveFolders("C:\Path")
End Sub
Sub RecursiveFolders(ByVal MyPath As String)
Dim FileSys As Object
Dim objFolder As Object
Dim objSubFolder As Object
Dim objFile As Object
Dim wkbOpen As Workbook
Set FileSys = CreateObject("Scripting.FileSystemObject")
Set objFolder = FileSys.GetFolder(MyPath)
Application.ScreenUpdating = False
For Each objSubFolder In objFolder.SubFolders
For Each objFile In objSubFolder.Files
Set wkbOpen = Workbooks.Open(Filename:=objFile)
'//Change the name of your macro, accordingly
Call Macro2
wkbOpen.Close savechanges:=True
Next
Call RecursiveFolders(objSubFolder.Path)
Next
Application.ScreenUpdating = True
End Sub