简体   繁体   中英

Access VBA getelementsbytagname windows 10 issue?

I have Access VBA scripts to pull data from a number of web sites. 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. 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:

Set objIE = CreateObject("InternetExplorer.Application")

Is there anything that upgrading Windows could have broken? (Novice, so apologies for any incorrect terminology)

Consider using the MSXML's IXMLHTTPRequest object for web server requests. IE is no longer a dedicated browser on Windows, so may not fully support automation going forward with 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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