I am looking for help on how to use VBA code behind a form in MS Access 2000 to:
1) Connect to a websites URL,
example: "
2) Pass a string to the webpage to populate a text box.
example: "IBM".
3) "Click" on a button on the webpage.
example: The "download" button.
4) Name the file:
example: "IBM_DataFile.txt"
5) Save the file to a stated folder on my PC.
example: "c:\data\Monday\"
Here is the code I have so far.
I did not write this code. It is a code sample from one of the many great posting here. I am pretty good at building frm, qry and rpts, but I am in over my head here and the help files are leaving me in circles.
The msgbox reports that the txt file downloaded, but no such luck. The path in the code is typed correct and the their is no copy of a file with that name to worry about over writting.
I'm not sure if I need to use the SendKeys method or find a way to interact with the HTML? SendKeys is such an "iffy" way of coding.
I am using IE as my browser, if it matters.
I know to some, this looks easy, but it is a new area for.
Thank you for sharing your time and talent.
1) Connect to a websites URL,
example: "
2) Pass a string to the webpage to populate a text box.
example: "IBM".
3) "Click" on a button on the webpage.
example: The "download" button.
4) Name the file:
example: "IBM_DataFile.txt"
5) Save the file to a stated folder on my PC.
example: "c:\data\Monday\"
Here is the code I have so far.
Code:
Private Sub cmdDownLoad_Click()
Dim FileAvailable As String
FileAvailable = funDownloadFile("[URL unfurl="true"]http://www.cboe.com/DelayedQuote/QuoteTableDownload.aspx",[/URL] "C:\data\Monday\IBM_DataFile.txt")
If FileAvailable = False Then 'No connection or file not found
MsgBox "File not found!"
Else
MsgBox "File successfully downloaded"
End If
End Sub
'-----------
'-----------
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
Private Const ERROR_SUCCESS As Long = 0
'-----------
Public Function funDownloadFile(sSourceUrl As String, _
sLocalFile As String) As Boolean
'if the API returns ERROR_SUCCESS (0),
'return True from the function
funDownloadFile = URLDownloadToFile(0&, _
sSourceUrl, _
sLocalFile, _
0&, _
0&) = ERROR_SUCCESS
End Function
I did not write this code. It is a code sample from one of the many great posting here. I am pretty good at building frm, qry and rpts, but I am in over my head here and the help files are leaving me in circles.
The msgbox reports that the txt file downloaded, but no such luck. The path in the code is typed correct and the their is no copy of a file with that name to worry about over writting.
I'm not sure if I need to use the SendKeys method or find a way to interact with the HTML? SendKeys is such an "iffy" way of coding.
I am using IE as my browser, if it matters.
I know to some, this looks easy, but it is a new area for.
Thank you for sharing your time and talent.