FranciscoRo
New Member
- Joined
- Feb 27, 2023
- Messages
- 4
- Office Version
- 2021
- Platform
- Windows
In order to download a PDF file to my computer, I use this code:
Sub descargar_archivo()
‘Descargo un archivo PDF y lo guardo en mi ordenador.
Dim FileUrl As String
Dim objXmlHttpReq As Object
Dim objStream As Object
FileUrl = "https://sede.agenciatributaria.gob.es/static_files/Sede/Tema/Destacados/Mod_repre/repre_2_es_es.pdf"
Set objXmlHttpReq = CreateObject("Microsoft.XMLHTTP")
objXmlHttpReq.Open "GET", FileUrl, False, "username", "password"
objXmlHttpReq.send
If objXmlHttpReq.Status = 200 Then
Set objStream = CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = 1
objStream.write objXmlHttpReq.responseBody
objStream.SaveToFile ThisWorkbook.Path & "\" & "file.pdf", 2
objStream.SaveToFile ThisWorkbook.Path, 2
objStream.Close
End If
End Sub
The previous code is useful for downloading a PDF file. Nevertheless, what I want to do now is to download a html file with all the images, buttoms, etc linked to it. I don´t get it . In some blogs some developers say that it’s posible to do it using Phyton or Selenium, but I don´t know how to use these aplications. What I know is Excel VBA. Any help will be wellcome.
Sub descargar_archivo()
‘Descargo un archivo PDF y lo guardo en mi ordenador.
Dim FileUrl As String
Dim objXmlHttpReq As Object
Dim objStream As Object
FileUrl = "https://sede.agenciatributaria.gob.es/static_files/Sede/Tema/Destacados/Mod_repre/repre_2_es_es.pdf"
Set objXmlHttpReq = CreateObject("Microsoft.XMLHTTP")
objXmlHttpReq.Open "GET", FileUrl, False, "username", "password"
objXmlHttpReq.send
If objXmlHttpReq.Status = 200 Then
Set objStream = CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = 1
objStream.write objXmlHttpReq.responseBody
objStream.SaveToFile ThisWorkbook.Path & "\" & "file.pdf", 2
objStream.SaveToFile ThisWorkbook.Path, 2
objStream.Close
End If
End Sub
The previous code is useful for downloading a PDF file. Nevertheless, what I want to do now is to download a html file with all the images, buttoms, etc linked to it. I don´t get it . In some blogs some developers say that it’s posible to do it using Phyton or Selenium, but I don´t know how to use these aplications. What I know is Excel VBA. Any help will be wellcome.