好的,我已经更新了整个线程的人。我的文本文件中有4个URL,前两个或3个打开,但是在打开第4个时,我的代码出现错误,如下所示:
Windows Script Host
Script: [file path]
Line: 23
Char: 3
Error: Unspecified error
Code: 80004005
Source: (null)
这就是我所拥有的:
Option Explicit
' Constants
Const ForReading = 1
Const navOpenInNewTab = 2048
Dim oIE, filename, fso, f
Set oIE = CreateObject("InternetExplorer.Application")
oIE.Visible = True
filename = "C:\StartIt\urls.txt"
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(filename, ForReading)
Do Until f.AtEndOfStream
If f.Line = 1 Then
oIE.Navigate2 removeDelimiter(f.ReadLine)
Else
oIE.Navigate2 removeDelimiter(f.ReadLine), navOpenInNewTab ' This is line 23
End if
Loop
Set oIE = Nothing
f.Close
WScript.Quit
' Methods
Function removeDelimiter(s)
If Right(s, 1) = "," Then
removeDelimiter = Left(s, Len(s) - 1)
Else
removeDelimiter = s
End If
End Function