Set ColFiles=objFolder.Files
I want to know the filename if there is only one file in a folder, so:
Set Colfiles=objFolder.files
if ColFiles.Count=1 then
<somecode>
end if
<somecode> COULD be:
For Each File in ColFiles
debug.print File.name
Next
But that doesn't seem efficient if I KNOW there's only ONE file. Can I do something like:
Colfiles(1).Name or Colfiles.item(1).name ? (I tried these... they do not work...)
objFolder.Files
-
- BronzeLounger
- Posts: 1246
- Joined: 03 Feb 2010, 19:59
- Location: Terneuzen, the Netherlands
-
- Administrator
- Posts: 78493
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: objFolder.Files
The Files collection does not behave like an array. You have to use For Each ... Next to get at its items.
Best wishes,
Hans
Hans
-
- BronzeLounger
- Posts: 1246
- Joined: 03 Feb 2010, 19:59
- Location: Terneuzen, the Netherlands
Re: objFolder.Files
Thanks