How do you write VBA code to download a file sitting behind a JavaScript link? There are many resources on how to download a file from a specific link using VBA, however, none show how to download a file behind a JavaScript link.
In example, how do you download the file behind "Export to Spreadsheet" on this website: https://www.vanguardinvestments.com.au/retail/ret/investments/product.html#/fundDetail/wholesale/portId=8101/assetCode=equity/?prices
Do we still declare and use urlmon?
'Declaration of API function for Office 2010+
Private Declare PtrSafe Function URLDownloadTOFile Lib "urlmon" Alias         
"URLDownloadToFileA" ( _
    ByVal pCaller As LongPtr, _
    ByVal sZURL As String, _
    ByVal szFileName As String, _
    ByVal dwReserved As LongPtr, _
    ByVal lpfnCB As LongPtr _
) As LongPtr
#Else
'Declaration of API function for pre Office 2010 versions
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
#End If
Sub DownloadOneFile()
    Dim FileURL As String
    Dim DestinationFile As String
    'How do you modify this to handle a javascript link?
    FileURL = "https://www.vanguardinvestments.com.au/retail/ret/investments/product.html#/fundDetail/wholesale/portId=8101/assetCode=equity/?prices"
    DestinationFile = "C:\VBA\prices.csv"
    URLDownloadToFile 0, FileURL, DestinationFile, 0, 0
End Sub
 
    