我正在尝试获取代码,通过它并删除所有标签,然后将其写入新文档 testfile.txt。出于某种原因,我在第 5 行收到错误: Set ts = f.openastextstream(forwriting, tristateusedefault) 并且收到错误无效过程。这是我的代码:
Sub elizabethwhite()
Set fs = CreateObject("scripting.filesystemobject")
fs.createtextfile "testfile.txt"
Set f = fs.getfile("testfile.txt")
Set ts = f.openastextstream(forwriting, tristateusedefault)
textline = ""
Do While f.opentextstream(forwriting, tristateusedefault).atendofstream <> True
textline = textline & f.opentextstream(forwriting, tristateusedefault).readline & "<BR>"
count = 0
pOne = 1
Do While InStr(textline, "<img") <> 0
count = count + 1
pOne = InStr(pOne, textline, "<img")
Do While InStr(pOne, textline, ">") = 0 & ts.atendofstream <> True
pTwo = InStr(pOne, textline, ">")
Loop
If 0 < count < 10 Then
textline = Left(textline, pOne - 1) & "{{image00" & count & ".jpg}}" & Right(textline, pTwo + 1)
ElseIf 9 < count < 100 Then
textline = Left(textline, pOne - 1) & "{{image0" & count & "}}.jpg" & Right(textline, pTwo + 1)
End If
Loop
Loop
ts.write textline
ts.Close
End Sub