Hi All,
I have script below that create msgbox after msgbox with a file name of the files in the folder, one by one, in alphabetical order.
Sub Macro123()
Set obFSO = CreateObject("Scripting.FileSystemObject")
Set mFolder = obFSO.GetFolder("C:\Temp\")
'temp = mainFolder.Files.Count
For Each MFile In mFolder.Files
MsgBox MFile.Name
Next
Set obFSO = Nothing
Set mFolder = Nothing
End Sub
if I use temp = mainFolder.Files.Count
And Count returns number 5 - meaning there are 5 files in the folder.
My question is: How I can using Msgbox to show only the last file?
I tryed something like MsgBox MFile(temp).Name but it does not work
Please help,
I have script below that create msgbox after msgbox with a file name of the files in the folder, one by one, in alphabetical order.
Sub Macro123()
Set obFSO = CreateObject("Scripting.FileSystemObject")
Set mFolder = obFSO.GetFolder("C:\Temp\")
'temp = mainFolder.Files.Count
For Each MFile In mFolder.Files
MsgBox MFile.Name
Next
Set obFSO = Nothing
Set mFolder = Nothing
End Sub
if I use temp = mainFolder.Files.Count
And Count returns number 5 - meaning there are 5 files in the folder.
My question is: How I can using Msgbox to show only the last file?
I tryed something like MsgBox MFile(temp).Name but it does not work
Please help,