可能重复:
Extract values from HTML TD and TrVB脚本或VBA代码到web网页的内容复制到Word/Excel工作表
我需要复制的web网页的内容使用VBA或VB脚本(如果使用任何编程语言繁忙)Word/Excel表单
所以,如果我给一个网页的路径,那么系统需要复制一个网页的内容和WR在Word或Excel文件中进行迭代。
可能重复:
Extract values from HTML TD and TrVB脚本或VBA代码到web网页的内容复制到Word/Excel工作表
我需要复制的web网页的内容使用VBA或VB脚本(如果使用任何编程语言繁忙)Word/Excel表单
所以,如果我给一个网页的路径,那么系统需要复制一个网页的内容和WR在Word或Excel文件中进行迭代。
请发表你媒体链接有下一次,我有2个解决方案,选择最适合您的需求,在这里如果你只是想查看HTML使用Word作为要求
Option Explicit
'Just change these two lines
Const HTMLFileIn="http://stackoverflow.com/questions/10782976/disable-error-in-vbs"
Const DocFileOut="c:\newfile.doc"
Dim MyWord,oIE
set MyWord=CreateObject("Word.Document")
Set oIE = CreateObject("InternetExplorer.Application")
oIE.Navigate HTMLFileIn
Wscript.Sleep 500
oIE.document.body.createTextRange.execCommand("Copy")
Wscript.Sleep 500
MyWord.Content.Paste
MyWord.SaveAs DocFileOut
MyWord.Close
oIE.Quit
Set oIE = Nothing
set MyWord = Nothing
Wscript.Echo HTMLFileIn & " is now saved as " & DocFileOut
Sub wait
Wscript.Sleep 500
While oIE.busy
Wscript.Sleep 1000
Wend
While oIE.Document.readyState <> "complete"
Wscript.Sleep 1000
Wend
End Sub
的一个,在这里是
url = "http://stackoverflow.com/questions/10782976/disable-error-in-vbs"
set xml = createobject("msxml2.serverxmlhttp.6.0")
with xml
.open "get", url, false
.send
wscript.echo .responsetext
end with
看我其他的答案最简单的解决方案,它使用的单词。 这里另一种技术和另存为HTML
function download(sFileURL, sLocation, async)
set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")
objXMLHTTP.open "GET", sFileURL, async
on error resume next
objXMLHTTP.send()
if err.number = 0 then
do until objXMLHTTP.Status = 200
wscript.echo objXMLHTTP.Status
wcript.sleep(200)
loop
if objXMLHTTP.Status = 200 Then
set objADOStream = CreateObject("ADODB.Stream")
objADOStream.Open
objADOStream.Type = 1
objADOStream.Write objXMLHTTP.ResponseBody
objADOStream.Position = 0
set objFSO = Createobject("Scripting.FileSystemObject")
If objFSO.Fileexists(sLocation) Then objFSO.DeleteFile sLocation
Set objFSO = Nothing
objADOStream.SaveToFile sLocation
objADOStream.Close
set objADOStream = Nothing
download = true
end if
else
download = false
end if
set objXMLHTTP = Nothing
end function
if download("http://stackoverflow.com/questions/10782976/disable-error-in-vbs", "question.html", false) then
wscript.echo "download ok"
else
wscript.echo "download nok"
end if