×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Chdir returns error

Chdir returns error

Chdir returns error

(OP)
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 !

RE: Chdir returns error

A couple of suggestions to try:
  • Change the line

    CODE

    DirPath = "K:\current\" + ResultsDate
    to

    CODE

    DirPath = "K:\current\" & ResultsDate
    & is the proper string concatenation operator in VBA
  • Inspect ResultsDate (while single-stepping through the code) for extra spaces.  If that's the case, you can remove using

    CODE

    Trim(ResultsDate)
Hope this helps,
Mike

RE: Chdir returns error

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources