tiredofit
Well-known Member
- Joined
- Apr 11, 2013
- Messages
- 1,924
- Office Version
- 365
- 2019
- Platform
- Windows
This code:
was adapted from here:
I want to convert it late binding.
I've tried this:
but it fails on this line:
How can I convert it to late binding?
Thanks
Code:
Private Sub LoopFolders(ByRef Loc As String)
Dim fso As Scripting.FileSystemObject
Set fso = New Scripting.FileSystemObject
Dim fol As Scripting.Folder
Dim f As Scripting.File
Dim subfol As Scripting.Folder
Set fol = fso.GetFolder(FolderPath:=Loc)
For Each f In fol.Files
Call GetInfo(f:=f)
Next f
For Each subfol In fol.SubFolders
Loc subfol.Path
Next subfol
Private Sub GetInfo(ByRef f As Scripting.File)
Call Workbooks.Open(Filename:=f.Path)
End Sub
was adapted from here:
Code:
https://www.wiseowl.co.uk/vba-macros/videos/vba-files-folders/files-folders/
I want to convert it late binding.
I've tried this:
Code:
Private Sub LoopFolders(ByRef Loc As String)
Dim fso As Object 'Scripting.FileSystemObject
Set fso = CreateObject("Scripting.FileSystemObject")
Dim fol As Object
Dim f As Object
Dim subfol As Object
Set fol = fso.GetFolder(FolderPath:=Loc)
For Each f In fol.Files
Call GetInfo(f:=f)
Next f
For Each subfol In fol.SubFolders
LoopFolders subfol.Path
Next subfol
End Sub
Private Sub GetInfo(ByRef f)
Call Workbooks.Open(Filename:=f.Path)
End Sub
but it fails on this line:
Code:
For Each f In fol.Files
How can I convert it to late binding?
Thanks