title: Download File from reporting services using VBA
body: <p>I have this script file. I am  attempting to download from reporting services using XMLHTTP. If i paste the url in my browser after logging in, the file pops up for download. However when running the code below, it does not work (The code does however work for downloading direct file links"</p>
  
  <p>How can i post the parameters and download the file from the report server? Really appreciate help on this one guys. Here is the code i am working with:</p>
  
  <pre><code>myURL = "http://example.com/reportviewer.aspx?id=1&amp;date=1/3/12&amp;format=PDF"
  
  Dim WinHttpReq As Object
  Set WinHttpReq = CreateObject("Microsoft.XMLHTTP")
  WinHttpReq.Open "GET", myURL, False, "user", "pwd"
  WinHttpReq.send
  
  myURL = WinHttpReq.responseBody
  If WinHttpReq.Status = 200 Then
      Set oStream = CreateObject("ADODB.Stream")
      oStream.Open
      oStream.Type = 1
      oStream.Write WinHttpReq.responseBody
      oStream.SaveToFile "C:\file.pdf", 2 
      oStream.Close
   End If
  </code></pre>
  
  <p>By the way the file that is returned (File.pdf) if i rename it to file.html and double click it. Internet explorer automatically popups up with a download notification. I tried to view the source of the file, but it is a link with a unique report execution id, so it will only be good for that one report. Also, the link in there is not to a pdf file but back to the report server.</p>