Code 800A0005 when using set objFile = objFSO.OpenTextFile

vbscript

Solution

Removing the `ForReading` portion of the line allows it to execute on my system using the following code:

'Saved in D:\TempFiles\TypeFile.vbs
set objFSO = CreateObject("Scripting.FileSystemObject") 
set objFile = objFSO.OpenTextFile("C:\Users\Ken\Desktop\Test.txt") 

Do Until objFile.AtEndOfStream 
    strLine = objFile.ReadLine 
    wscript.echo strLine
Loop

I tested using a simple `Test.txt` containing the following:

Line 1
Line 2
Line 3
Line 4
Line 5
Line 6

I tested it using the following at a command prompt:

D:\TempFiles>cscript TypeFile.vbs

I received this output:

Note: An additional problem you'll encounter is using `set` on this line (and perhaps the one that follows it):

set indi = 2

`indi` is a simple variable, not an object, and therefore there's no need for `set`. Just assign the value directly:

indi = 2

Problem

I have searched this error code numerous times and have gone to numerous sites to read responses. Long story short, still haven't found a solution. One page referenced: Error while sending ( character with sendkeys in vbscript Here is my code: ``` set WshShell = WScript.CreateObject("WScript.Shell") Return = WshShell.Run("C:\Downloads\software\putty.exe -load navstat") DIM date date = 301113 DIM tran1 tran1 = TAFFY set objFSO = CreateObject("Scripting.FileSystemObject") set objFile = objFSO.OpenTextFile("C:\Users\Adrian\Desktop\Entries1.txt", ForReading) Do Until objFile.AtEndOfStream strLine = objFile.ReadLine If InStr(strLine, "JFK.GREKI3.MARTN..TOPPS") Then set indi = 2 set tran1 = TOPPS End If Loop ``` What's going on: I am scanning a .txt file (Entries1.txt) for text strings. If they occur I need to set corresponding indi values (so when indi is used later as a variable it will use the correct #) and change the tran1 variables as well. For some reason I'm getting an error at: ``` set objFile = objFSO.OpenTextFile ``` The error is Invalid procedure call or argument Code: 800A0005 Help would be greatly appreciated.

Original source