Problem with DIR

S

SamMy

ChangeFileOpenDirectory _
"C:\Documents and Settings\Smith\My Documents\TXT\"
Dir (activedirectory & "*.doc")
fname = Dir

If in that directory (TXT) exists only one file, fname is empty. If there
are two or more files, then fname is the first filename it founds.

What's the problem with this?
 
H

Helmut Weber

Hi,
you are calling "dir" twice!
Dir (activedirectory & "*.doc") ' 1st time
fname = Dir ' 2nd time

you need something like
fname = (activedirectory & "*.doc") '1st file

while fname <> ""
fname = dir ' successive files
wend
 
Top