我收到错误
800A0401 - 预期结束声明
在VBScript中。
请澄清错误。
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("C:\Users\RAJDIQ\Desktop\Macros\11082017\SingleFile.txt", ForReading)
strLine = objTextFile.ReadLine
Set folder = objFSO.GetFolder("C:\Users\RAJDIQ\Desktop\Macros\11082017\")
Set outfile = objFSO.OpenTextFile("C:\Users\RAJDIQ\Desktop\Macros\11082017\comparedel.txt")
myFile ="C:\Users\RAJDIQ\Desktop\Macros\11082017\Output.txt"
Open myFile for Output As #1
t = 0
Do Until outfile.AtEndOfStream
strLine = outfile.ReadLine
If InStr(strLine, substrToFind) <> 0 Then
t = t+1
Else
[ Lines = Lines & t & ","
Write #1, Lines]
End If
Loop
MsgBox "Complete"
答案 0 :(得分:0)
你把VBA与VBScript混淆了。 Open myFile for Output As #1
不是有效的VBScript代码,也不是Write #1
或方括号。在VBScript中,您可以通过FileSystemObject
处理文件。
Set outputFile = objFSO.OpenTextFile(myFile, 2, True)
'stuff
outputFile.WriteLine "something"
'more stuff
outputFile.Close
参数2
打开要写入的文件,参数True
可确保创建文件以防丢失。
请查看documentation了解详情。