Consulting

Results 1 to 3 of 3

Thread: Open File not working

  1. #1

    Open File not working

    FileName.jpgSo when I run through the code line by line, at Debug.Print(FileName) in the immediate window shows me the correct file that I'm looking for, but when It goes to Open fileName For Input As #1 it says "file not found". I'm pretty new to VBA but if in the immediate window right before shows the right file why is it saying it cannot find it when the code tries to open it?

  2. #2
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    It is better to paste code between code tags than an image. Click # icon in reply toolbar to insert the tags.

    If you get a result from Dir(), that just means that a file exists. You need to concatenate the filepath and filename. e.g.
    Open filepath & filename For Input as #1

  3. #3
    Ahhh Thank you Kenneth I will do that with my code from now on, I was misunderstanding the use of Dir(). I was never actually combining the path and name, thank you again for the help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •