filmov
tv
VBA Loop on files in folder

Показать описание
Loop on all files in a folder within your macro
Code:
Sub loop_on_files_in_folder()
Dim myFolder As Object
Dim path_myFolder As String
Dim current_file As Object
Dim name_current_file As String
'identify path of the folder
path_myFolder = "C:\Users\brunduk\Documents\Tutorials\"
Set Fso = CreateObject("Scripting.FileSystemObject")
'identify folder
'loop on files of the folder
For Each current_file In myFolder.Files
'name of current file within the loop
name_current_file = current_file.Name
'display name of the current file
MsgBox ("Current file's name: " & name_current_file)
Next
End Sub
-------------------------------
NEED HELP?
-------------------------------
Leave a comment with your questions, issues or projetcs and I will try to answer with a video.
-------------------------------
THANK YOU
-------------------------------
For watching my videos,
Your shares
And your comments!
Code:
Sub loop_on_files_in_folder()
Dim myFolder As Object
Dim path_myFolder As String
Dim current_file As Object
Dim name_current_file As String
'identify path of the folder
path_myFolder = "C:\Users\brunduk\Documents\Tutorials\"
Set Fso = CreateObject("Scripting.FileSystemObject")
'identify folder
'loop on files of the folder
For Each current_file In myFolder.Files
'name of current file within the loop
name_current_file = current_file.Name
'display name of the current file
MsgBox ("Current file's name: " & name_current_file)
Next
End Sub
-------------------------------
NEED HELP?
-------------------------------
Leave a comment with your questions, issues or projetcs and I will try to answer with a video.
-------------------------------
THANK YOU
-------------------------------
For watching my videos,
Your shares
And your comments!