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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top