|
aspx网站不能直接导入进Excel里。啃pdf文档不知关键在哪章节,在这个论坛知识树里参考粘贴网页方法,但,这么简短的vba代码就是通不过,提示运行 自动化错误,好像就是个CreateObject参数问题。
F8如下图。vba代码也贴进来了。
请大侠指导,不甚感激!!!
Public Sub tableTest()
Dim txt, web
Set web = CreateObject("MSXML2.XMLHTTP")
web.Open "Get", "https://www.taiwanlottery.com.tw/Lotto/BINGOBINGO/drawing.aspx", False
web.send ' https://www.crsky.com/soft/134082.html 这网址可行的通
txt = web.responseText
txt = "<table>" & HtmlFilter(txt, "table_f"">", "</table>")
PutClipboard txt
Cells.Clear
Range("a1").Select
ActiveSheet.Paste
End Sub
Public Function HtmlFilter(ByVal htmlText$, Label1$, label2$) '返回html字符串lable1和最近的lable2标签中的数据
Dim pStart As Long, pStop As Long '开始位置,结束位置
pStart = InStr(htmlText, Label1) + Len(Label1) '找到标签信息的起始位置
pStop = InStr(pStart, htmlText, label2)
HtmlFilter = htmlText ' HtmlFilter = Mid(htmlText, pStart, pStop - pStart)
End Function
Public Sub PutClipboard(ByVal tt$) 'tt放入剪贴板
With CreateObject("new:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}") '调试用,数据放入剪贴板
.SetText tt
.PutInClipboard
End With
End Sub
|
|