I have a VBScript that I am working on building. The script itself complets all of the functions within it – it throws an error only after the script ends. It is giving me the following error:
vbscript runtime error: Object required 'objFSO'
Here is the relavant function:
Function ReadFileIntoArray (sFile)
dim objFSO 'As FileSystemObject
dim file
dim volumes()
Set file = objFSO.OpenTextFile(sFile) 'Error Thrown Here.
do while not file.AtendOfStream
redim preserve text(nlines)
volumes(nlines) = file.Readline
nlines = nlines + 1
loop
file.close
set file = nothing
Set objFSO = nothing
ReadFileIntoArray = volumes
end Function
The file is still opened and used properly. I'm a little lost. Any ideas?
Best Answer
objFSO
is never assigned a value. When the error occurs,objFSO
's value isEmpty
, which is not an object.You're probably missing