This specific content was written 13 years ago.
Please keep this in mind as it may be outdated and not adhering to best-practices.
The below is from an answer I posted on stackoverflow.
You can retrieve the chemical structure of an image using the following:
Sub Run()
getImage ("iron")
End Sub
Public Function getImage(ByVal name As String) As String
Dim imgURL As String
Dim XMLhttp: Set XMLhttp = CreateObject("MSXML2.ServerXMLHTTP")
XMLhttp.setTimeouts 1000, 1000, 1000, 1000
imgURL = "http://cactus.nci.nih.gov/chemical/structure/" + name + "/image"
XMLhttp.Open "GET", imgURL, False
XMLhttp.send
If XMLhttp.Status = 200 Then
'It exists so get the image
Sheets(1).Shapes.AddPicture imgURL, msoFalse, msoTrue, 100, 100, 250, 250
Else
'
End If
End Function
This can further simplified to simply only use
Sheets(1).Shapes.AddPicture imgURL, msoFalse, msoTrue, 100, 100, 300, 300
Instead of downloading the image the twice, and simply using an error handler to catch when image not found.
Reference:
Apr 22 2014
Mozilla has disallowed javascript: execution via the address bar
If you try running javascript code via the address bar (not not from a bookmark) it no longer works as mozilla has disabled it for 2 years now.
Trying the following:
javascript:alert("hello");Causes the following error to appear in the error console:
By Chris Georgoulis • Uncategorized 0