Hey,
I'm trying to create something in Excel so that we are able to know when our standards go out of date, as - for some unknown reason - this is not something that can be done online or via. a reliable service.
Essentially, I have column with standards, ie. AS_4021_1 and another column with the date of the standard, ie. 2018. My intentions are to run a macro in vba that will open IE, take the standard name and search it through '
This is where I am encountering two errors, the first being the '=IE.document.getElementsByClassName' which is giving me all of the innertext of "product-item--bodyspan10" when all i'm wanting is the AS"####-##" bit.
The second problem being I have to include the Application.wait as without this I seem to receive multiple of the same result (as i'm guessing IE just cannot keep up with the program, and the while IE.Busy doesn't seem to alleviate this problem.
Any help would be greatly appreciated,
Thanks
I'm trying to create something in Excel so that we are able to know when our standards go out of date, as - for some unknown reason - this is not something that can be done online or via. a reliable service.
Essentially, I have column with standards, ie. AS_4021_1 and another column with the date of the standard, ie. 2018. My intentions are to run a macro in vba that will open IE, take the standard name and search it through '
https://infostore.saiglobal.com/en-au/Search/All/?searchTerm="STANDARD NAME HERE"', return the title of the first result from this webpage (which can be used to retrieve the year of the most current publication) and create a hyperlink.
From here I will be able to run the macro, see all publications which are supposedly out of date and follow the hyperlinks to see where either the macro has returned the wrong result, or our publication is out of date.
Currently I have;
From here I will be able to run the macro, see all publications which are supposedly out of date and follow the hyperlinks to see where either the macro has returned the wrong result, or our publication is out of date.
Currently I have;
Code:
Dim cell As Range, Rng As Range
Sheets("Check").Range("B2:B" & Range("B" & Rows.Count).End(xlUp).Row).Select
For Each cell In Rng
If cell.Hyperlinks.Count = 0 Then
ActiveSheet.Hyperlinks.Add Anchor:=cell, _
Address:="https://infostore.saiglobal.com/en-au/Search/All/?searchTerm=" & cell.Value
End If
Next
This just sets the range as all cells with a value in the standard name column, and creates the hyperlinks in these cells. (These cells are taken automatically from another worksheet). This part seems to work fine.
Code:
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = False
For Each cell In Rng
With cell
IE.navigate "https://infostore.saiglobal.com/en-au/Search/All/?searchTerm=" & cell.Value
While IE.Busy
DoEvents
Wend
Application.Wait (Now + TimeValue("0:00:03"))
cell.Offset(, 2) = IE.document.getElementsByClassName("product-item--body span10")(0).innerText
End With
Next
End Sub
This is where I am encountering two errors, the first being the '=IE.document.getElementsByClassName' which is giving me all of the innertext of "product-item--bodyspan10" when all i'm wanting is the AS"####-##" bit.
The second problem being I have to include the Application.wait as without this I seem to receive multiple of the same result (as i'm guessing IE just cannot keep up with the program, and the while IE.Busy doesn't seem to alleviate this problem.
Any help would be greatly appreciated,
Thanks