https vba javascript

phibs

New Member
Joined
Sep 12, 2018
Messages
1
I'm trying to access a https page to download a PDF file that is returned by the server with the following url format: https://xxx/clApp?xxxxx=makeReport&xxxx&endDate=31aug18&beginDate=01aug18
Code:
<code>Sub SavePdfFromURL()  

Dim fileUrl As String
Dim filePath As String
Dim WHTTP As Object  

fileUrl = "https://xx/clApp?xx&xxEndDate=31aug18&beginDate=01aug18"
filePath = "C:\Users\xxx\Desktop\duty.pdf"  

Set WHTTP = CreateObject("WinHTTP.WinHTTPrequest.5.1")  

WHTTP.Open "GET", fileUrl, False
WHTTP.setRequestHeader "Content-Type", "application/pdf"
WHTTP.send
If WHTTP.Status = 200 Then
   Set oStream = CreateObject("ADODB.Stream")
      oStream.Open
      oStream.Type = 1
      oStream.Write WHTTP.responsebody
      oStream.SaveToFile filePath, 1
      oStream.Close
End If  

MsgBox "File has been saved!", vbInformation, "Success"</code>
I started using httpreq but have no idea how to deal with javascript page. If i copy this link to a web browser it directly opens the pdf viewer.
Thanks for your Help.
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

Forum statistics

Threads
1,215,325
Messages
6,124,254
Members
449,149
Latest member
mwdbActuary

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top