I'm writing a android app and I need a fairly big databas for it. I'm using Excel and vba to construct this databas. I've been googling quite a bit and in order to download a webpage (to extract data to my databas) and I've come up with the below code. But it's not working. It always returns downloadResult=2148270085. Anyone with any good suggestions for a solution? I'm on a 64-bit system and using EXCEL2013 64-bit version.
Option Explicit
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
Sub DownloadFileButton_Clicked()
Dim fileURL As String
Dim fileName As String
Dim downloadResult As LongPtr
fileURL = "http://www.wordreference.com/definicion/estar"
fileName = Application.ThisWorkbook.Path + "\" + "estar.htm"
downloadResult = URLDownloadToFile(0, fileURL, fileName, 0, 0)
If downloadResult = 0 then
Debug.Print "Download started"
Else
Debug.Print "Download not started, error code: " & downloadResult
End If
End Sub