PDA

View Full Version : [SOLVED] Open File not working



TeeJBeams
08-27-2019, 12:14 PM
24883So 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?

Kenneth Hobs
08-27-2019, 12:59 PM
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

TeeJBeams
08-27-2019, 02:26 PM
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.