Guest User

Untitled

a guest
Jan 17th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.61 KB | None | 0 0
  1. onclick="ga('send', 'event', 'Downloads', 'XLS', 'https://www.england.nhs.uk/statistics/wp-content/uploads/sites/2/2018/01/LA-Type-B-November-2017-2ayZP.xls');"
  2.  
  3. Option Explicit
  4.  
  5. Public Sub DownloadDTOC()
  6.  
  7. Dim http As New XMLHTTP60
  8. Dim html As New HTMLDocument
  9. Dim CurrentWindow As HTMLWindowProxy
  10.  
  11. With http
  12. .Open "GET", "https://www.england.nhs.uk/statistics/statistical-work-areas/delayed-transfers-of-care/delayed-transfers-of-care-data-2017-18/", False
  13. .send
  14. html.body.innerHTML = .responseText
  15. End With
  16.  
  17. On Error GoTo Errhand
  18.  
  19. 'Call html.parentWindow.execScript("ga('send', 'event', 'Downloads', 'XLS', 'https://www.england.nhs.uk/statistics/wp-content/uploads/sites/2/2018/01/LA-Type-B-November-2017-2ayZP.xls');", "Javascript") '-2147352319 Automation error
  20.  
  21. 'Call html.frames(0).execScript("ga('send', 'event', 'Downloads', 'XLS', 'https://www.england.nhs.uk/statistics/wp-content/uploads/sites/2/2018/01/LA-Type-B-November-2017-2ayZP.xls');", "Javascript") '438 Object doesn't support this property or method
  22. 'automation error
  23.  
  24. 'Call currentWindow.execScript("ga('send', 'event', 'Downloads', 'XLS', 'https://www.england.nhs.uk/statistics/wp-content/uploads/sites/2/2018/01/LA-Type-B-November-2017-2ayZP.xls');", "Javascript") ' 91 Object variable or With block variable not set
  25.  
  26. Set CurrentWindow = html.parentWindow
  27. Call CurrentWindow.execScript("ga('send', 'event', 'Downloads', 'XLS', 'https://www.england.nhs.uk/statistics/wp-content/uploads/sites/2/2018/01/LA-Type-B-November-2017-2ayZP.xls');", "Javascript") '--2147352319 Could not complete the operation due to error 80020101.
  28.  
  29. Exit Sub
  30.  
  31. Errhand:
  32. If Err.Number <> 0 Then Debug.Print Err.Number, Err.Description
  33. End Sub
  34.  
  35. Public Sub DownloadDTOC()
  36. Dim IE As New InternetExplorer, http As New XMLHTTP60
  37. Dim html As HTMLDocument, post As Object
  38.  
  39. With IE
  40. .Visible = True
  41. .navigate "https://www.england.nhs.uk/statistics/statistical-work-areas/delayed-transfers-of-care/delayed-transfers-of-care-data-2017-18/"
  42. While .Busy Or .readyState < 4: DoEvents: Wend
  43. Set html = .Document
  44. End With
  45.  
  46. For Each post In html.getElementsByClassName("xls-link")
  47. tempArr = Split(post.href, "/")
  48. tempArr = tempArr(UBound(tempArr))
  49.  
  50. http.Open "GET", post.href, False
  51. http.send
  52.  
  53. With CreateObject("ADODB.Stream")
  54. .Open
  55. .Type = 1
  56. .write http.responseBody
  57. .SaveToFile ("D:TestImages" & tempArr) ''change it according to your address
  58. .Close
  59. End With
  60. Next post
  61. IE.Quit
  62. End Sub
Add Comment
Please, Sign In to add comment