View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Harlan Grove[_5_] Harlan Grove[_5_] is offline
external usenet poster
 
Posts: 97
Default Combine all text file in directory into one file.

"Rich" wrote...
I changed the code to the following, but am getting a run-time error
76 "Path not found" on the line:
Open "C:\ECPJM\" & SrcFiles(Counter) For Input As #2

However the path is spelled correctly and I even copied it from
Windows Explorer. Any ideas?


The problem may be interpretting 'path'. By 'path' do you mean just the
"C:\ECPJM\" piece, i.e., the directory path? If so, that's one problem. The term
'path' in this context means the file's full path name. Try adding a statement
just above this like

Debug.Print Counter, "C:\ECPJM\" & SrcFiles(Counter)

to see what the file's full pathname appears to be to Excel/VBA. I suspect the
segment

Do While sName < ""
i = i + 1
SrcFiles(i) = sName
sName = Dir
Loop
ReDim SrcFiles(1 To i)


is the source of the problem. Try changing the ReDim statement to

ReDim Preserve SrcFiles(1 To i)

--
To top-post is human, to bottom-post and snip is sublime.