Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Chdir returns error

Status
Not open for further replies.

prash1972

Computer
Oct 26, 2005
1
I have the following scenario. A shell script writes the name of the directory (Example: 10-24-05) into a text file progress.txt. I have a VBA Macro reading this file to pick up the name of the directory to change to. I am using the following code to do this:

Open "I:\tests\progress.txt" For Input As #20
Line Input #20, ResultsDate
Close #20
DirPath = "K:\current\" + ResultsDate
ChDir DirPath

When I run this, I see an error saying the path was not found. But incase I assign ResultsDate = "10-24-05" instead of reading it from a file, that seems to work fine. Can anyone tell me what I might be doing wrong ?
Thanks !
 
Replies continue below

Recommended for you

A couple of suggestions to try:
[ul]
[li]Change the line
Code:
DirPath = "K:\current\" + ResultsDate
to
Code:
DirPath = "K:\current\" [b]&[/b] ResultsDate
& is the proper string concatenation operator in VBA[/li]

[li]Inspect ResultsDate (while single-stepping through the code) for extra spaces. If that's the case, you can remove using
Code:
Trim(ResultsDate)
[/li]
[/ul]

Hope this helps,
Mike
 
There are a number of characters which cannot be used in the name of a directory or file. You might want to verify that the date, as read from the progress.txt file, does not contain any illegal characters.


Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor