If you feed something that VBScript can use as a string to .OpenTextFile, the method will try to open a file and perhaps throw a "file not found" error.
>> strInputPath1 = "C:\test" & "\" & "css" & "\" & "main.css"
>> WScript.Echo strInputPath1
>> set f = goFS.OpenTextFile(strInputPath1,1)
>>
C:\test\css\main.css
Error Number: 76
Error Description: Path not found
To get an "Invalid procedure call" error, you have to pass something sinister, e.g. an Empty value:
>> strInputPath1 = Empty
>> set f = goFS.OpenTextFile(strInputPath1,1)
>>
Error Number: 5
Error Description: Invalid procedure call or argument
These facts make it highly probable that you
- either changed the content of the variable strInputPath1 between its initialization and its use in .OpenTextFile()
- or initialized a variable X and used a variable Y (Y & X may be variations of "strInputPath1")
- or initialized and used two variables of the same name in different scopes (~Functions/Subs)
Starting your scripts with "Option Explicit" will reduce the risk of such blunders.
Added wrt "got the fso named wrong" comment:
As VBScript's error messages are often hard to interpret/understand, this may be a good opportunity to reflect on "What can go wrong? What will VBScript tell me about the problem? What should I do to fix the error? How can I avoid it in the future?"
Given a stringy first parameter and a typo (=> empty variable) in goFS:
>> strInputPath1 = "C:\test" & "\" & "css" & "\" & "main.css"
>> set f = goSF.OpenTextFile(strInputPath1,1)
>>
Error Number: 424
Error Description: Object required
Stands to reason: Trying to call a method (. operator) without an object on the left of the dot is a no-no.
Let's Set the evil goSF to an object:
>> Set goSF = New RegExp
>> set f = goSF.OpenTextFile(strInputPath1,1)
>>
Error Number: 438
Error Description: Object doesn't support this property or method
Still no "invalid procedure call or argument" error. As goSF now is a RegExp, let's ignore the specific method(name) - OpenTextFile() - and see what happens if we mess up the call:
>> WScript.Echo TypeName(goSF)
>> Set ms = goSF.Execute()
>>
IRegExp2
Error Number: 450
Error Description: Wrong number of arguments or invalid property assignment
>> Set ms = goSF.Execute(Null)
>>
Error Number: 13
Error Description: Type mismatch
So my claim still stands. The error "Invalid procedure call or argument" was caused by feeding Empty to the method .OpenTextFile() called on a valid FSO.