Jump to content

Cant find file with objFSO.OpenTextFile


Recommended Posts

Hi all, im new to this forum. Just started programming with VBS, at the real beginner level. Im running into some difficulty and Google nor any forum could give me the anwser, so im gonna give it a try here. I've got the following code which is giving diffuculties.

Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile(doel, ForReading)
sRead = objTextFile.Read(2)The third line ("doel" is a variable which contains the path to a file) gives an error File not found (800A0035). I use a msgbox to check whether the path is correct, which it is. I've tried adding True right behind ForReading, which creates a file with exactly the same name as the file im trying to read, in exactly the same folder. This makes me wonder if it has anything to do with permissions, or filetype or something. The path that i'm using is the entire path including filename and .txt. I've tried copying the file to the root of C:. Then i get an error permission denied. It does however seems to find the file.
Could anyone shed some light on what im doing wrong?
Thanks in advance!
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...