dimanche 1 mars 2015

VBA - Opening a website and saving it as a .GIF extension

I am trying to open and then save a web page which contains an image as a .GIF extension to my desktop. The below code opens a test page for me:



Sub test()
Dim IE As Object, Doc As Object
Set IE = CreateObject("internetexplorer.application")
IE.Visible = True
IE.Navigate "http://ift.tt/1rTMOYY"

Do While IE.ReadyState <> 4: DoEvents: Loop
Set Doc = CreateObject("htmlfile")
Set Doc = IE.Document
End Sub


The next step is saving the page as a .GIF. The manual process for doing this is either right clicking the image and pressing save and then adding the .gif extension to the name or another way is to just press CTRL+S on the page and save it as an image that way.


I have tried API function URLDownloadToFile however the image I am using for my application updates every time the page is refreshed and I require the saved image to be the same as the one open therefore, cannot use the above function as it results in the two different images.


If possible, I am trying to avoid using SendKeys for this.





Aucun commentaire:

Enregistrer un commentaire