Yzerman19
-
Total Posts
:
5
- Scores: 0
-
Reward points
:
0
- Joined: 12/18/2011
-
Status: offline
|
For Each Loop not working.
Sunday, December 18, 2011 4:55 PM
( permalink)
First post here. I'm trying to loop through a folder to get the files within, but for some odd reason the For Each loop only goes through once, here's my code: Dim k
k = 0
For Each pdf2 In pdfDir.Files
k = k+1
Next
Wscript.echo k
Wscript.Quit The output of the echo is always 1, but I have 3 files within the pdfDir directory, what's the problem? This VBScript is within a wsf file, I'm not sure if this makes a difference or not but it's really frustrating that the For Each loop is not working (Other loops do work).
|
|
|
|
thenson81
-
Total Posts
:
8
- Scores: 0
-
Reward points
:
0
- Joined: 12/18/2011
-
Status: offline
|
Re:For Each Loop not working.
Sunday, December 18, 2011 5:00 PM
( permalink)
pretty sure all my file work was done more by using set files = pdfDir.files for each pdf2 in files k = k + 1 next not sure if it matters doing it this way but all my for each work fine
|
|
|
|
Yzerman19
-
Total Posts
:
5
- Scores: 0
-
Reward points
:
0
- Joined: 12/18/2011
-
Status: offline
|
Re:For Each Loop not working.
Sunday, December 18, 2011 5:03 PM
( permalink)
Thanks for the reply. I tried it that way too, no luck. It only loops once. This does not make sense at all.
|
|
|
|
Yzerman19
-
Total Posts
:
5
- Scores: 0
-
Reward points
:
0
- Joined: 12/18/2011
-
Status: offline
|
Re:For Each Loop not working.
Sunday, December 18, 2011 5:34 PM
( permalink)
Ok, as I debug, pdfDir.Files returns empty, why would it return empty when there are 3 files in the folder?
|
|
|
|
Yzerman19
-
Total Posts
:
5
- Scores: 0
-
Reward points
:
0
- Joined: 12/18/2011
-
Status: offline
|
Re:For Each Loop not working.
Sunday, December 18, 2011 5:47 PM
( permalink)
|
|
|
|