简体   繁体   English

访问VBA getelementsbytagname Windows 10问题?

[英]Access VBA getelementsbytagname windows 10 issue?

I have Access VBA scripts to pull data from a number of web sites. 我有Access VBA脚本,可以从许多网站中提取数据。 These worked perfectly with office 2013 and Windows 7. However, since upgrading to Windows 10 I have been getting intermittent errors (not necessarily in the same place with the same data) or sometimes data is not being extracted from the tags. 它们与Office 2013和Windows 7完美配合。但是,自从升级到Windows 10以来,我一直遇到间歇性错误(不一定在同一位置使用相同的数据),或者有时未从标记中提取数据。 It appears too occur when I access a specific tag with a specific index eg 当我使用特定索引访问特定标签时,也会出现这种情况

tempV = TDelement.getElementsByTagName("td")(0).innerText

I'm using IE as the browser object created as follows: 我使用IE作为创建的浏览器对象,如下所示:

Set objIE = CreateObject("InternetExplorer.Application")

Is there anything that upgrading Windows could have broken? Windows升级有什么坏处吗? (Novice, so apologies for any incorrect terminology) (新手,因此对任何不正确的术语表示歉意)

Consider using the MSXML's IXMLHTTPRequest object for web server requests. 考虑将MSXML的IXMLHTTPRequest对象用于Web服务器请求。 IE is no longer a dedicated browser on Windows, so may not fully support automation going forward with Windows 10. IE不再是Windows上的专用浏览器,因此可能不再完全支持Windows 10以后的自动化。

Dim Req As Object, xmlobj As Object
Dim strWeb As String, myFile As String

' READ HTML PAGE
Set Req = CreateObject("MSXML2.XMLHTTP")
Req.Open "GET", "http://www.example.coms/", False
Req.send

' HTML/TEXT
strWeb = Req.responseText
myFile = "C:\Path\To\File.txt"
Open myFile For Output As #1
Write #1, strWeb
Close #1

' XML
Set xmlObj = CreateObject("MSXML2.DOMDocument")
myFile = "C:\Path\To\File.xml"
xmlObj.LoadXML Req.responseText
xmlObj.Save myFile

Set Req = Nothing
Set xmlObj = Nothing

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM