Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opening Text file for Input Problems.

Status
Not open for further replies.

EddyLLC

Technical User
Mar 15, 2005
304
US
I found the following code in an earlier thread and modified it but I did something wrong. I define strFolderName in a startup routine. When I stop the code and check values strFile is set to a file in the appropriate directory but when it gets to the Open for Input statement the Error File not found appears. What did I miss?

Dim strFile As String

strFile = Dir(strFolderName & "", vbNormal)
Do While (Len(strFile) > 0)
Open strFile For Input As #1
' various operations
strFile = Dir
Loop
 
Perhaps something like this ?
Open strFolderName & "\" & strFile For Input As #1

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Very strange. I tried you code and the first time through it worked fine. I found another error farther down in the code. The second time I tried it strFile is being set to "" even though there are files in the appropriate directory. I am perplexed. Thanks
 
Probably strFolderName was reset ...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
You were right, It works great now. Thanks for the help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top