Vb用于将网页内容复制到word / excel表的脚本或VBA代码 [英] Vb Script or VBA code to copy the contents of a web webpage to a word/excel sheet
本文介绍了Vb用于将网页内容复制到word / excel表的脚本或VBA代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:
从HTML TD和Tr中提取值
我需要使用VBA或VB脚本(如果它忙于使用任何编程语言)将网页的内容复制到word / excel表。
I need to copy the contents of a web webpage to a word/excel sheet using VBA or VB Script (If it hectic the using any programming language)..
如果我给出一个网页的路径,那么系统需要复制一个网页的内容,并写在Word或excel文件中。
So if i give the path of a web page then the system needs to copy the contents of a web page and write it in a Word or excel file.
推荐答案
请发布您下一次已经有,我有2个解决方案,选择最适合您的需要,这里是使用字作为请求的
Please post what you allready have next time, i have 2 solutions, choose what best suits your needs, here the one that use word as requested
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
这篇关于Vb用于将网页内容复制到word / excel表的脚本或VBA代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文