title: html file download from web with URLDownloadToFile creates empty file
body: <p>I have a problem which has been discussed in this forum in the past, but although solutions for the specific cases had been proposed, none has been useful for me.
  I want to analyze a data table containing recent stock quotes. Precisely this is a Yahoo portfolio. The URL is "<a href="https://finance.yahoo.com/portfolio/pf_5/view/view_0" rel="nofollow noreferrer">https://finance.yahoo.com/portfolio/pf_5/view/view_0</a>". 
  If I try to import the portfolio to my worksheet via a web connection, there is no content to be seen in the importation window. This work fine until some time ago, but it seems that Yahoo has changed the code, so that the content cannot be imported anymore. So I cannot use the website in an Excel connection to import my portfolio anymore.</p>
  
  <p>But I can download the file with Chrome without entering credentials (they are already stored in Chrome or in a cookie, don't know) to my download folder as an html-file and when I open it in a browser it will not only show like the original but I can also analyze the downloaded file with Excel. The file length of the file downloaded directly from the browser is 256 kB.
  So it seems that the server recognizes how the file is being used and allows storing it, but not analyzing it online.</p>
  
  <p>Now I am trying to write a vba sub that opens the website, downloads the file and then analyzes the stored version.
  The analysis part works fine, but I am not able to include a working download in the code. 
  When I use the URLDownloadToFile(0, URL1, URL2, 0, 0) method (URL1 is the https address and URL2 is the file name and path), the downloaded file has only 75kB and contains some java code, but there are no data to be seen on the screen when I watch it with the browser and when I try to import the content to Excel, nothing will be imported.
  So while URLDownloadToFile may work in most cases, it does not work with the Yahoo portfolio web pages.
  My question is:
  1) could it help changing the parameters of the function (parameter 1 = pcaller?). But how?
  2) is there any other known method available in vba to save a web page without reading it line by line (tried this, too and doesn't work either) ?
  These are two methods I tried:</p>
  
  <pre><code>  Option Explicit
   'Declarations
  Private Declare Function URLDownloadToFile Lib "urlmon" _
  Alias "URLDownloadToFileA" (ByVal pCaller As Long, _
  ByVal szURL As String, ByVal szFileName As String, _
  ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
  
   'Download Code
  Sub download()
  
  Dim done
  Dim URL1 As String
  Dim URL2 As String
  
  URL1 = "https://finance.yahoo.com/portfolio/pf_5/view/v1"
  URL2 = "C:\Users\xxx\Downloads\pf1 - Yahoo Finance Portfolios.html"
  
   'This will provide a return value to test.
   'Note the  (   )  around the args
  done = URLDownloadToFile(0, URL1, URL2, 0, 0)
  
   'Test.
  If done = 0 Then
      MsgBox "File has been downloaded!"
  Else
      MsgBox "File not found!"
  End If
  
  End Sub
  </code></pre>
  
  <hr>
  
  <pre><code>Sub SaveWebFile()   'this creates an "empty" file!
  Dim URL1 As String
  Dim URL2 As String
  
  URL1 = "https://finance.yahoo.com/portfolio/pf_5/view/v1"
  URL2 = "C:\Users\xxxx\Downloads\pf1 - Yahoo Finance Portfolios.html"
  
  Set fso = CreateObject("Scripting.fileSystemObject")
     With CreateObject("MSXML2.XMLHTTP")
     .Open "GET", URL1, False
     .send
     Text = .responseText
     End With
   Set objOutputFile = fso.CreateTextFile(URL2, True)
   objOutputFile.Write Text
   objOutputFile.Close
  
  End Sub
  </code></pre>